Memories API - Nest.js + Typescript + Prisma + PostgreSQL /p>
$ npm install# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod- The application will run at 8080, you can chnage the port from ./src/main.ts
- This is a short documentation for the all routes handled.
- The errors are handled - More infos will be added to the documentation later.
POST /auth/register
{
# all fields are required
"email":"tony@thesopranos.com",
"username":"tony",
"password":"tony123"
}Status: 201 CREATED
{
"access_token": "jwt_token",
"refresh_token": "jwt_token"
}GET /auth/signin
{
# all fields are required
"email":"tony@thesopranos.com",
"password":"tony123"
}Status: 200 OK
{
"access_token": "jwt_token",
"refresh_token": "jwt_token"
}POST /auth/logout
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
"message": "Logged out!"
}POST /auth/refresh
# Authorization header(Bearer) required. (refresh_token)Status: 200 OK
{
"access_token": "jwt_token",
"refresh_token": "jwt_token"
}GET /memories/
Status: 200 OK
# array of memories
[
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
# array of strings
"hashtags": [],
"ownerId": "",
"owner": {
"email": "",
"username": "",
"profile": {
"image": "",
"bio": "",
"name": ""
}
},
"_count": {
"comments": 0 , # number of comments
"likedBy": 2 # number of likes
}
}
]POST /memories
# Authorization header(Bearer) required. (access_token){
# all fields are required
"title":"New memorie",
"description":"This is a description!",
"image":"image_link",
"hashtags":["afc","pl"]
}Status: 201 CREATED
{
"memorieId": "",
"title": "New memorie",
"description": "This is the description!!",
"image": "",
"hashtags": ["afc", "pl"],
"ownerId": ""
}GET /memories/:id
# id (valid uuid ) requiredStatus: 200 OK
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": "",
"owner": {
"userId": "",
"email": "",
"username": "",
"profile": {
"image": "",
"bio": "",
"name": ""
}
},
"comments": [ # array of comments
{
"commentId": "",
"title": "",
"content": "",
"authorId": "",
"memorieId": ""
}
],
"likedBy": [ # array of users who liked the memorie
{
"userId": "",
"username": "",
"profile": {
"image": ""
}
}
]
}PUT /memories/:id
# id (valid uuid ) required
# Authorization header(Bearer) required. (access_token){
# all fields are required
"title":"",
"description":"",
"image":"",
"hashtags":[]
}Status: 200 OK
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}DELETE /memories/:id
# id (valid uuid ) required
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}POST /memories/:id/like
# id (valid uuid ) required
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}DELETE /memories/:id/like
# id (valid uuid ) required
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}POST /memories/:id/comments
# id (valid uuid ) is required. (id of the memorie)
# Authorization header(Bearer) required. (access_token){
# all fields are required
"title":"",
"content":""
}Status: 201 CREATED
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}DELETE /memories/:id/comments/:commentId
# id (valid uuid ) is required. (id of the memorie)
# commentId (valid uuid ) is also required.
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}Get /me/
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
"userId": "",
"email": "",
"username": "",
"profile": {
"bio": "",
"image": "",
"name": ""
},
# array of liked memories
"likedMemories": [],
# array of current user's memories
"memories": [],
# array of users who follow the current user
"followers": [],
# array of users whom the current user follow
"following": []
}Get /me/
# Authorization header(Bearer) required. (access_token)Status: 200 OK
[
{
"memorieId": "",
"title": "",
"description": "",
"image": "",
"hashtags": [],
"ownerId": ""
}
]- Update an exisiting profile, or create one if it doesn't exist.
PUT /me/profile
# Authorization header(Bearer) required. (access_token){
"name": "",
"bio": "",
"image": ""
}Status: 200 OK
{
"profileId": "",
"name": "",
"bio": "",
"image": "",
"userId": ""
}GET /me/followers
# Authorization header(Bearer) required. (access_token)Status: 200 OK
[
# array of users
]DELETE /me/followers/:id
# id (valid uuid) required
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
# follower(user) removed
}GET /me/following
# Authorization header(Bearer) required. (access_token)Status: 200 OK
[
# array of users
]POST /me/following/:id
# id (valid uuid) required
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
# user followed
}DELETE /me/following/:id
# id (valid uuid) required
# Authorization header(Bearer) required. (access_token)Status: 200 OK
{
# user unfollowed
}- Author - Oussama Lamnaouer
- Website - https://laous.netlify.app
- Twitter - @oussamalm__