- Basic authentication (sign-in/sign-up/password recovery with OTP).
- Authorization with scalable role-based access control.
- Swagger API documentation.
- Article/blog management system (CRUD).
- The example server is deployed at Render with Docker.
- Install NodeJS
- Run it with version 22.x
$ cd server & npm install
- Copy
.env.example
and fill them up by indicated fields in.env
file. In caseblog-server
has no connection to database, fill.env
file withENV=development
andDATABASE=localhost
.
$ cp .env.example .env
- Start
docker-compose.yml
to run bothblog-server
andpostgres
.
$ docker compose -p docker-compose up
- Check status for
postgres
container and ensure it runs properly. In case there is no active status frompostgres
container, rundocker ps -a
and look for itcontainer_id
then start the container withdocker start container_id
. - Run
blog-server
with any below options:
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
- Render currently doesn't support for Docker Compose so running it in deployment environment makes no sense. Try to deploy a
postgre
first and fill its information on.env
for production enviroment. I recommend to try deploypostgres
on Render. - Change
.env
withENV=production
to enable SSL/TLS connection.
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
- Experience APIs through Swagger API documentation (host/docs). Any specifications should be indicated by summary of each API.
blog-server
only provides default administrator account with personal setup in.env
file with fieldADMIN_USERNAME
,ADMIN_EMAIL
,ADMIN_PASSWORD
. You have to sign up in order to create new account (reader role by default). To experience new role, there is/auth/change-role/{id}
endpoint for granting roles to any accounts. Read more in docs.- For password recovery feature, you have to setup mail host for sending users OTP via email. Setup that in these fields in
.env
file:MAIL_HOST
,MAIL_USER
,MAIL_PASSWORD
,MAIL_FROM
,MAIL_PORT
(587 for default gmail port). This feature requires valid email for both sender and receiver.