To promote the decentralization process of SpacePi, the official website of SpacePi(ETH) is now open source.
The SpacePi code released on this website (space-pi.com) is open-sourced solely to promote community development. Any actions taken by third parties, including but not limited to any community, organization, or individual, using this code for any statements, inducements, investments, promotions, or similar activities, are not associated with this website. This website is not responsible for any losses or legal consequences arising from such actions and does not assume any liability in any form.
- Clone the repository to your local machine
git clone https://github.com/SpacePiCom/SpacePi-ETH-Frontend.git
- Navigate to the project directory
cd SpacePi-ETH-Frontend
- Install dependencies
yarn install
-
Run the development server
yarn dev
After running, you can view the project in your browser at
http://localhost:82
. -
Build the project
yarn build
The built files will be output to the
dist
directory.
The worker.js
script is used to handle different types of requests to the server, such as API requests and page requests.
-
Ensure
worker.js
is included in your project directory. -
In
worker.js
, set up an event listener for fetch events to handle requests:addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); });
-
Implement
handleRequest
to route requests to appropriate handlers based on the request path:async function handleRequest(request) { const { pathname } = new URL(request.url); if (pathname.startsWith('/api')) { return handleAPIRequest(request); } else { return handlePageRequest(request); } }
-
Define functions
handleAPIRequest
andhandlePageRequest
to process API and page requests respectively.
For more details, refer to the comments and documentation within worker.js
.
yarn dev
: Start the development server with hot module replacement.yarn build
: Build the project for production and generate optimized static files.
If you have any questions, you can contact me via:
- Email: [email protected]
- GitHub: SpacePiCom