API service for blog application. Built with authentication, middleware, dto validation, database, OOP and other concepts and principles.
- Express
- TypeScript
- Class Validator and Class Transformer for DTO validation
- Prisma
- Mongo DB
- Docker for running Mongo
- JWT
I used Docker to pull and run container with MongoDB:
docker pull prismagraphql/mongo-single-replica:5.0.3
-
docker run --name mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME="user" -e MONGO_INITDB_ROOT_PASSWORD="root" -d prismagraphql/mongo-single-replica:5.0.3
- Copy and set up all contents for
.env.local
(create this file), use.env.example
as template - Do not forget to edit
DATABASE_URL
in.env.local
and add there necessary port (here - 27017), user (here "user") and password (here "root") npm install
npm run prisma:db-push-local
npm run prisma:generate-local
npm run start:dev
/api/v1
/users
/:id
, GET/:id
, PUT/current
, GET
/auth
/login
, POST/register
, POST
/posts
/
, GET/
, POST/:id
, GET/:id
, DELETE