Create .env
file with the following content:
DATABASE_URL="file:./data/dev.db"
JWT_ACCESS_SECRET=SECRET123
JWT_REFRESH_SECRET=ANOTHER_SECRET123
npm install
npm run migrate
npm run dev
Server available at http://localhost:3010
docker build --tag spaceorbit-server:1.0 .
docker run -t -i -p 3010:3010 \
--rm --name spaceorbit \
--volume spaceorbitDB:/container/src/db/data \
spaceorbit-server:1.0
-p
forwards container's ports-ti
allowsCTRL + C
to stop container--rm
removes container after exit--name
becomes hostname for containers--volume
makes database data persistent by creating a named volume
Server available at http://localhost:3010
Unfold to see the list of all API Routes of SpaceOrbit-server
POST /users/register
POST /users/login
POST /users/refreshToken
GET /users/me
POST /users/resetPassword
GET /users/resetPassword/:id
GET /users
POST /users
GET /users/:id
PATCH /users/:id
DELETE /users/:id
GET /endpoints
- Refresh Token ― allows for acquirement of more Access Tokens
- Valid for 8 hours
- Requires check against db per use
- Revocation is immediate
- Access Token ― provides access to protected routes
- Valid for 5 minutes
- Does not require check against db per use
- Revocation is not immediate: users could still use Access Token for up to 5 minutes even with revoked Refresh Token
Logout is achieved by clearing tokens from local/session storage on the client
Repository design pattern
- Server entry point at /src/core/app.ts
- Models are defined at /src/db/schema.prisma
- Database is stored at /src/db/data
- Controllers are defined at /src/controllers/*
- Middleware are defined at /src/middleware/*
- Routes are defined at /src/routes/*
- Services are defined at /src/services/*
- Utility functions are defined at /src/utils/*