├── .gitignore ├── nodemon.json ├── src ├── api │ ├── category │ │ ├── category.interface.ts │ │ ├── category.class.ts │ │ ├── category.route.ts │ │ └── category.controller.ts │ ├── user │ │ ├── user.interface.ts │ │ ├── user.route.ts │ │ ├── user.class.ts │ │ └── user.controller.ts │ ├── post │ │ ├── post.interface.ts │ │ ├── post.class.ts │ │ ├── post.route.ts │ │ └── post.controller.ts │ └── index.ts ├── index.ts ├── config │ ├── mongodb.config.ts │ ├── success.codes.ts │ ├── error.codes.ts │ └── config.ts ├── helpers │ ├── responses.handler.ts │ └── error.handler.ts └── app.ts ├── Dockerfile ├── tsconfig.json ├── .github └── workflows │ ├── label-bot.yml │ ├── heroku-cd.yml │ ├── node.js.yml │ └── docker-publish.yml ├── README.md ├── package.json └── docs ├── swagger └── Code Kitty Prep API.postman_collection-oyMQvKqonTe2jYeqDmU8yd.json ├── er-diagram.drawio └── postman └── Code Kitty Prep API.postman_collection.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .idea/ 4 | *.env 5 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "exec": "ts-node ./index.ts" 5 | } -------------------------------------------------------------------------------- /src/api/category/category.interface.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from "mongoose"; 2 | 3 | export default interface ICategory extends mongoose.Document { 4 | name: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/api/user/user.interface.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from "mongoose"; 2 | 3 | export interface IUser extends mongoose.Document { 4 | displayName: string; 5 | email: string; 6 | photoURL: string; 7 | uid: string; 8 | } 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14-alpine 2 | 3 | RUN mkdir /app 4 | 5 | WORKDIR /app 6 | 7 | COPY package.json package-lock.json ./ 8 | 9 | RUN npm install 10 | 11 | COPY . . 12 | 13 | EXPOSE 4000 14 | 15 | RUN npm build 16 | 17 | CMD ["npm", "start"] -------------------------------------------------------------------------------- /src/api/post/post.interface.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from "mongoose"; 2 | 3 | export interface IPost extends mongoose.Document { 4 | description: string; 5 | imageURL: string; 6 | createdDate: string; 7 | userId: string; 8 | categoryName: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import app from "./app"; 2 | import config from "./config/config"; 3 | 4 | const PORT: number = parseInt(config.PORT) || 4000; 5 | const HOST = "0.0.0.0"; 6 | 7 | app.listen(PORT, HOST, () => { 8 | console.log(`Server running on port ${PORT}`); 9 | }); 10 | -------------------------------------------------------------------------------- /src/api/category/category.class.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from 'mongoose'; 2 | import ICategory from './category.interface'; 3 | 4 | export const CategorySchema = new mongoose.Schema({ 5 | name: { type: String, required: true }, 6 | }); 7 | 8 | export default mongoose.model('Category', CategorySchema); 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "sourceMap": true, 7 | "resolveJsonModule": true, 8 | "lib": ["dom", "es2017"] 9 | }, 10 | "include": ["src/**/*.ts", "src"], 11 | "exclude": ["node_modules"] 12 | } -------------------------------------------------------------------------------- /src/api/user/user.route.ts: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import Controller from "./user.controller"; 3 | 4 | const user: Router = Router(); 5 | const controller = new Controller(); 6 | 7 | user.post("/", controller.addUser); 8 | user.get("/:id", controller.getUser); 9 | user.get("/", controller.getAllUsers); 10 | user.put("/", controller.updateUser); 11 | user.delete("/:id", controller.deleteUser); 12 | 13 | export default user; 14 | -------------------------------------------------------------------------------- /src/api/index.ts: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import user from "./user/user.route"; 3 | import category from "./category/category.route"; 4 | import post from "./post/post.route" 5 | 6 | const router = Router(); 7 | 8 | router.get("/", (req, res) => { 9 | res.send("Hello Code Kitty!"); 10 | }); 11 | 12 | router.use("/user", user); 13 | router.use("/category", category); 14 | router.use("/post", post); 15 | 16 | export default router; 17 | -------------------------------------------------------------------------------- /src/api/user/user.class.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from "mongoose"; 2 | import { IUser } from "./user.interface"; 3 | 4 | export const UserSchema = new mongoose.Schema({ 5 | displayName: { type: String, required: true }, 6 | email: { type: String, required: true }, 7 | photoURL: { type: String, required: true }, 8 | uid: { type: String, required: true }, 9 | }); 10 | 11 | const User = mongoose.model("User", UserSchema); 12 | export default User; 13 | -------------------------------------------------------------------------------- /.github/workflows/label-bot.yml: -------------------------------------------------------------------------------- 1 | on: pull_request_review 2 | name: Label approved pull requests 3 | jobs: 4 | labelWhenApproved: 5 | name: Label when approved 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Label when approved 9 | uses: pullreminders/label-when-approved-action@master 10 | env: 11 | APPROVALS: "1" 12 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 13 | ADD_LABEL: "approved" 14 | REMOVE_LABEL: "review%20needed" 15 | -------------------------------------------------------------------------------- /src/config/mongodb.config.ts: -------------------------------------------------------------------------------- 1 | import * as mongo from "mongodb"; 2 | 3 | export class MongoHelper { 4 | public static client: mongo.MongoClient; 5 | 6 | public static async connect(url: string): Promise { 7 | try { 8 | this.client = await mongo.MongoClient.connect(url, { 9 | 10 | }); 11 | } catch (e) { 12 | throw e; 13 | } 14 | } 15 | 16 | public async disconnect(): Promise { 17 | await MongoHelper.client.close(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Code Kitty API 2 | 3 | ### How to start backend server 4 | 5 | 1. Open Terminal 6 | 2. `yarn install` or `npm install` 7 | 3. `yarn run dev` or `npm run dev` 8 | 9 | #### Installation of ts-node: 10 | 11 | Since we are using NodeTS in our project, we will have to separately install this as a dependency. 12 | 13 | Run `npm install -g ts-node` 14 | 15 | 16 | **You should get the following output on the terminal/git bash:** 17 | 18 | Code Kitty Server is listening on 4000 19 | 20 | Connected to MongoDB! 21 | -------------------------------------------------------------------------------- /src/api/post/post.class.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from "mongoose"; 2 | import { IPost } from "./post.interface"; 3 | 4 | export const PostSchema = new mongoose.Schema({ 5 | description: { type: String, required: true }, 6 | imageURL: { type: String, required: true }, 7 | createdDate: { type: String, required: true }, 8 | userId: { type: String, required: true, ref: "User" }, 9 | categoryName: { type: String, required: true }, 10 | }); 11 | 12 | const Post = mongoose.model("Post", PostSchema); 13 | export default Post; 14 | -------------------------------------------------------------------------------- /src/config/success.codes.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | SUCCESSFULLY_AUTHORIZED: "SUCCESSFULLY AUTHORIZED", 3 | SUCCESSFULLY_USER_CREATED: "SUCCESSFULLY USER CREATED", 4 | SUCCESSFULLY_USER_UPDATED: "SUCCESSFULLY USER UPDATED", 5 | SUCCESSFULLY_USER_DELETED: "SUCCESSFULLY USER DELETED", 6 | SUCCESSFULLY_DATA_RETRIVED: "SUCCESSFULLY DATA RETRIEVED", 7 | SUCCESSFULLY_DATA_ADDED: "SUCCESSFULLY DATA ADDED", 8 | SUCCESSFULLY_DATA_UPDATED: "SUCCESSFULLY DATA UPDATED", 9 | SUCCESSFULLY_DATA_DELETED: "SUCCESSFULLY DATA DELETED", 10 | }; 11 | -------------------------------------------------------------------------------- /src/api/post/post.route.ts: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import Controller from "./post.controller"; 3 | 4 | const post: Router = Router(); 5 | const controller = new Controller(); 6 | 7 | post.post("/", controller.addPost); 8 | post.get("/:id", controller.getPost); 9 | post.get("/", controller.getAllPost); 10 | post.put("/", controller.updatePost); 11 | post.delete("/:id", controller.deletePost); 12 | post.get("/users/all", controller.getAllPostsWithUsers); 13 | post.get("/user/:id", controller.getPostsByUser); 14 | 15 | export default post; 16 | -------------------------------------------------------------------------------- /src/config/error.codes.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | UNAUTHORIZED: "UNAUTHORIZED", 3 | REGISTRATION_FAILED: "REGISTRATION FAILED", 4 | TOKEN_EXPIRED: "TOKEN EXPIRED", 5 | INTERNAL_ERROR: "INTERNAL ERROR", 6 | BAD_REQUEST: "BAD REQUEST", 7 | USER_ALREADY_EXISTS: "USER ALREADY EXISTS", 8 | USER_UPDATE_FAILED: "USER UPDATE FAILED", 9 | DATA_UPDATE_FAILED: "DATA UPDATE FAILED", 10 | PERMISSION_DENIED: "PERMISSION DENIED", 11 | INVALID_TOKEN: "INVALID TOKEN", 12 | INVALID_TYPE: "INVALID TYPE", 13 | ALREADY_EXIST: "ALREADY EXIST", 14 | }; 15 | -------------------------------------------------------------------------------- /src/api/category/category.route.ts: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import Controller from "./category.controller"; 3 | 4 | const category: Router = Router(); 5 | const controller = new Controller(); 6 | 7 | category.get('/', controller.getAllCategories); // get all categories 8 | category.get('/:id', controller.getCategoryById); // get category by id 9 | category.post('/', controller.addCategory); // create new category 10 | category.put('/:id', controller.updateCategory); // update category 11 | category.delete('/:id', controller.deleteCategory); // delete category 12 | 13 | export default category; 14 | -------------------------------------------------------------------------------- /src/helpers/responses.handler.ts: -------------------------------------------------------------------------------- 1 | // failed response format 2 | function failed(errorCode: string, statusCode: number = 400) { 3 | return { 4 | success: false, 5 | errorCode: errorCode, 6 | statusCode: statusCode, 7 | }; 8 | } 9 | 10 | // success response format 11 | function success(message) { 12 | return { 13 | success: true, 14 | message: message, 15 | }; 16 | } 17 | 18 | // success response format 19 | function successWithPayload(message, data) { 20 | return { 21 | success: true, 22 | data: data, 23 | message: message, 24 | }; 25 | } 26 | 27 | export { failed, success, successWithPayload }; 28 | -------------------------------------------------------------------------------- /src/config/config.ts: -------------------------------------------------------------------------------- 1 | import * as dotenv from "dotenv"; 2 | 3 | dotenv.config(); 4 | 5 | const PORT = process.env.PORT; 6 | const DB_USERNAME = process.env.DB_USERNAME; 7 | const DB_PASSWORD = process.env.DB_PASSWORD; 8 | const DB_HOST = process.env.DB_HOST; 9 | const DB_NAME = process.env.DB_NAME; 10 | const MONGO_DB_URI = `mongodb+srv://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}?retryWrites=true&w=majority`; 11 | 12 | export default { 13 | PORT: PORT, 14 | MONGO_DB_URI: MONGO_DB_URI, 15 | DB_NAME: DB_NAME, 16 | USER_COLLECTION_NAME: "user", 17 | CATEGORY_COLLECTION_NAME: "category", 18 | POST_COLLECTION_NAME: "post", 19 | }; 20 | -------------------------------------------------------------------------------- /src/helpers/error.handler.ts: -------------------------------------------------------------------------------- 1 | import * as httpStatus from "http-status"; 2 | 3 | // handle not found errors 4 | export const notFound = (req, res, next) => { 5 | res.status(httpStatus.NOT_FOUND).send({ 6 | success: false, 7 | message: "Requested Resource Not Found", 8 | }); 9 | }; 10 | 11 | // handle internal server errors 12 | export const internalServerError = (err, req, res, next) => { 13 | res.status(err.status || httpStatus.INTERNAL_SERVER_ERROR).send({ 14 | success: false, 15 | message: err.message, 16 | }); 17 | }; 18 | 19 | // handle bad request errors 20 | export const badRequest = (err, req, res, next) => { 21 | res.status(err.status || httpStatus.BAD_REQUEST).send({ 22 | success: false, 23 | message: err.errors, 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /.github/workflows/heroku-cd.yml: -------------------------------------------------------------------------------- 1 | name: Heroku Docker Registry Deploy 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | # Allows you to run this workflow manually from the Actions tab 8 | workflow_dispatch: 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | 16 | steps: 17 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 18 | - uses: actions/checkout@v2 19 | 20 | - name: Build, Push and Release a Docker container to Heroku. 21 | uses: gonuit/heroku-docker-deploy@v1.3.3 22 | with: 23 | email: hcsperera@gmail.com 24 | heroku_api_key: ${{ secrets.HEROKU_API_KEY }} 25 | heroku_app_name: code-kitty-api 26 | dockerfile_directory: . 27 | dockerfile_name: Dockerfile 28 | docker_options: "--no-cache" 29 | process_type: web 30 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: CodeKitty API CI 5 | 6 | on: 7 | pull_request: 8 | branches: [ main ] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | strategy: 16 | matrix: 17 | node-version: [16.x] 18 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Use Node.js ${{ matrix.node-version }} 23 | uses: actions/setup-node@v2 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | cache: 'npm' 27 | - run: npm ci 28 | - run: npm run build --if-present 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codekitty/code-kittty-api", 3 | "version": "1.0.0", 4 | "description": "Code Kitty API", 5 | "main": "index.js", 6 | "directories": { 7 | "doc": "docs" 8 | }, 9 | "scripts": { 10 | "start": "tsc && node dist/index.js", 11 | "dev": "nodemon --exec ts-node src/index.ts", 12 | "build": "tsc", 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "author": "Chamod, Safnaj, Shreya", 16 | "license": "ISC", 17 | "dependencies": { 18 | "@types/mongodb": "^4.0.7", 19 | "@types/mongoose": "^5.11.97", 20 | "body-parser": "^1.19.0", 21 | "cors": "^2.8.5", 22 | "dotenv": "^10.0.0", 23 | "express": "^4.17.1", 24 | "http-status": "^1.5.0", 25 | "mongodb": "^4.1.0", 26 | "mongoose": "^5.13.7", 27 | "morgan": "^1.10.0", 28 | "prettier": "^2.4.0", 29 | "typescript": "^4.3.5" 30 | }, 31 | "devDependencies": { 32 | "@types/cors": "^2.8.12", 33 | "@types/express": "^4.17.13", 34 | "@types/morgan": "^1.9.3", 35 | "nodemon": "^2.0.15" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Registry Image Push 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | build: 9 | runs-on: 10 | - ubuntu-latest 11 | env: 12 | SERVICE_NAME: ghcr.io/codekittyshow/code-kitty-api 13 | CONTAINER_REGISTRY: ghcr.io 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Set Version 17 | id: event-version 18 | run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} 19 | - name: Cache Docker layers 20 | uses: actions/cache@v2 21 | with: 22 | path: /tmp/.buildx-cache 23 | key: ${{ runner.os }}-buildx-${{ github.sha }} 24 | restore-keys: | 25 | ${{ runner.os }}-buildx- 26 | - name: Login to GitHub Container Registry 27 | uses: docker/login-action@v1 28 | with: 29 | registry: ${{ env.CONTAINER_REGISTRY }} 30 | username: ${{ github.actor }} 31 | password: ${{ secrets.GH_TOKEN }} 32 | - name: Build the Docker image 33 | run: docker build --tag ${SERVICE_NAME}:latest --file Dockerfile . 34 | - name: GitHub Image Push 35 | run: docker push $SERVICE_NAME:latest 36 | -------------------------------------------------------------------------------- /src/app.ts: -------------------------------------------------------------------------------- 1 | import * as express from "express"; 2 | import * as cors from "cors"; 3 | import * as morgan from "morgan"; 4 | import * as bodyParser from "body-parser"; 5 | import apiV1 from "./api"; 6 | import { MongoHelper } from "./config/mongodb.config"; 7 | import Config from "./config/config"; 8 | import * as errorHandler from "./helpers/error.handler"; 9 | 10 | class App { 11 | public express: express.Application; 12 | 13 | constructor() { 14 | this.express = express(); 15 | this.setMiddlware(); 16 | this.setRoutes(); 17 | this.connectToDB(); 18 | this.catchError(); 19 | } 20 | 21 | private setMiddlware(): void { 22 | this.express.use(cors()); 23 | this.express.use(bodyParser.json()); 24 | this.express.use(morgan("dev")); 25 | } 26 | 27 | private setRoutes(): void { 28 | this.express.use("/api/v1", apiV1); 29 | } 30 | 31 | private async connectToDB(): Promise { 32 | const MONGO_DB_URI = Config.MONGO_DB_URI; 33 | try { 34 | await MongoHelper.connect(MONGO_DB_URI); 35 | console.info(`Connected to MongoDB!`); 36 | } catch (e) { 37 | console.error(`Unable to connect to MongoDB!`, e.message); 38 | } 39 | } 40 | 41 | private catchError(): void { 42 | this.express.use(errorHandler.notFound); 43 | this.express.use(errorHandler.internalServerError); 44 | this.express.use(errorHandler.badRequest); 45 | } 46 | } 47 | 48 | export default new App().express; 49 | -------------------------------------------------------------------------------- /docs/swagger/Code Kitty Prep API.postman_collection-oyMQvKqonTe2jYeqDmU8yd.json: -------------------------------------------------------------------------------- 1 | {"openapi":"3.0.0","servers":[{"url":"http://localhost:4000","description":"","variables":{}}],"info":{"version":"35bdf8b3-3a95-45a2-a179-26d580f4959e","title":"Code Kitty Prep API","description":"","termsOfService":"","contact":{},"license":{"name":""}},"paths":{"/api/v1/post/1":{"delete":{"summary":"Delete Post","operationId":"DeletePost","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Posts"]},"get":{"summary":"Get Post By Id","operationId":"GetPostById","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Posts"]}},"/api/v1/post":{"post":{"summary":"Add Post","operationId":"AddPost","parameters":[],"responses":{"200":{"description":"","headers":{}}},"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","example":{"description":"aaaa","imageURL":"string","createdDate":"string","userId":"612211ba1cc1fa106465ca11","categoryName":"string"}},"example":"{\n \"description\": \"aaaa\",\n \"imageURL\": \"string\",\n \"createdDate\": \"string\",\n \"userId\": \"612211ba1cc1fa106465ca11\",\n \"categoryName\": \"string\"\n}"}}},"tags":["Posts"]},"put":{"summary":"Update Post","operationId":"UpdatePost","parameters":[],"responses":{"200":{"description":"","headers":{}}},"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","example":{"_id":"","description":"","imageURL":"string","createdDate":"string","userId":"string","categoryName":"string"}},"example":"{\n \"_id\":\"\",\n \"description\": \"\",\n \"imageURL\": \"string\",\n \"createdDate\": \"string\",\n \"userId\": \"string\",\n \"categoryName\": \"string\"\n}"}}},"tags":["Posts"]},"get":{"summary":"Get All Posts","operationId":"GetAllPosts","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Posts"]}},"/api/v1/post/users/all":{"get":{"summary":"Get Posts with Users","operationId":"GetPostswithUsers","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Posts"]}},"/api/v1/category":{"post":{"summary":"Add Category","operationId":"AddCategory","parameters":[],"responses":{"200":{"description":"","headers":{}}},"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","example":{"name":"Care"}},"example":"{\n \"name\": \"Care\"\n}"}}},"tags":["Category"]},"put":{"summary":"Update Category","operationId":"UpdateCategory","parameters":[],"responses":{"200":{"description":"","headers":{}}},"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","example":{"_id":"","name":""}},"example":"{\n \"_id\": \"\",\n \"name\": \"\"\n}"}}},"tags":["Category"]},"get":{"summary":"Get All Categories","operationId":"GetAllCategories","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Category"]}},"/api/v1/category/1":{"delete":{"summary":"Delete Category","operationId":"DeleteCategory","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Category"]},"get":{"summary":"Get Category By ID","operationId":"GetCategoryByID","parameters":[],"responses":{"200":{"description":"","headers":{}}},"tags":["Category"]}},"/api/v1/user":{"post":{"summary":"Create User","operationId":"CreateUser","parameters":[],"responses":{"200":{"description":"","headers":{}}},"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","example":{"displayName":"Chamod Perera","email":"hcsperera@gmail.com","photoURL":"dsdsdsdsds","uid":"dsdsdsd"}},"example":"{\n \"displayName\": \"Chamod Perera\",\n \"email\": \"hcsperera@gmail.com\",\n \"photoURL\": \"dsdsdsdsds\",\n \"uid\": \"dsdsdsd\"\n}"}}},"tags":["User"]}}},"components":{},"security":[],"tags":[],"externalDocs":{"url":"","description":""},"warnings":[]} -------------------------------------------------------------------------------- /src/api/user/user.controller.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from "express"; 2 | import * as mongodb from "mongodb"; 3 | import { MongoHelper } from "../../config/mongodb.config"; 4 | import User from "./user.class"; 5 | import Config from "../../config/config"; 6 | import ErrorCodes from "../../config/error.codes"; 7 | import SuccessCodes from "../../config/success.codes"; 8 | import * as httpStatus from "http-status"; 9 | import * as responses from "../../helpers/responses.handler"; 10 | 11 | const getCollection = () => { 12 | return MongoHelper.client 13 | .db(Config.DB_NAME) 14 | .collection(Config.USER_COLLECTION_NAME); 15 | }; 16 | 17 | export default class UserController { 18 | public addUser = async (req: Request, res: Response): Promise => { 19 | const requestData = req.body; 20 | const collection = getCollection(); 21 | const userData = new User(requestData); 22 | try { 23 | const { uid } = requestData; 24 | const user = await collection.findOne({ uid }); 25 | 26 | if (user) { 27 | res 28 | .status(httpStatus.OK) 29 | .send(responses.success(ErrorCodes.USER_ALREADY_EXISTS)); 30 | res.end(); 31 | return; 32 | } 33 | await collection.insertOne(userData); 34 | 35 | res 36 | .status(httpStatus.CREATED) 37 | .send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_ADDED)); 38 | res.end(); 39 | } catch (e) { 40 | console.error(e.message); 41 | res.send( 42 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 43 | ); 44 | } 45 | }; 46 | 47 | public getUser = async (req: Request, res: Response): Promise => { 48 | const collection = getCollection(); 49 | 50 | try { 51 | const user = await collection.findOne({ 52 | uid: req.params.id, 53 | }); 54 | 55 | res.send( 56 | responses.successWithPayload( 57 | SuccessCodes.SUCCESSFULLY_DATA_RETRIVED, 58 | user 59 | ) 60 | ); 61 | } catch (e) { 62 | console.error(e.message); 63 | res.send( 64 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 65 | ); 66 | } 67 | }; 68 | 69 | public getAllUsers = async (req: Request, res: Response): Promise => { 70 | const collection: any = getCollection(); 71 | 72 | try { 73 | const data = await collection.find().toArray(); 74 | 75 | res.send( 76 | responses.successWithPayload( 77 | SuccessCodes.SUCCESSFULLY_DATA_RETRIVED, 78 | data 79 | ) 80 | ); 81 | } catch (e) { 82 | console.error(e.message); 83 | res.send( 84 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 85 | ); 86 | } 87 | }; 88 | 89 | public updateUser = async (req: Request, res: Response): Promise => { 90 | const { uid, displayName, email, photoURL } = req.body; 91 | 92 | const collection: any = getCollection(); 93 | 94 | try { 95 | await collection.findOneAndUpdate( 96 | { uid: new mongodb.ObjectId(uid) }, 97 | { $set: { displayName, email, photoURL } } 98 | ); 99 | 100 | res.send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_UPDATED)); 101 | } catch (e) { 102 | console.error(e.message); 103 | res.send( 104 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 105 | ); 106 | } 107 | }; 108 | 109 | public deleteUser = async (req: Request, res: Response): Promise => { 110 | const id = req.params.id; 111 | const collection: any = getCollection(); 112 | 113 | try { 114 | await collection.deleteOne({ uid: new mongodb.ObjectId(id) }); 115 | res.send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_DELETED)); 116 | } catch (e) { 117 | console.error(e.message); 118 | res.send( 119 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 120 | ); 121 | } 122 | }; 123 | } 124 | -------------------------------------------------------------------------------- /src/api/category/category.controller.ts: -------------------------------------------------------------------------------- 1 | import { Request , Response} from 'express'; 2 | import { ObjectId } from 'mongodb'; 3 | import { MongoHelper } from "../../config/mongodb.config"; 4 | import Config from "../../config/config"; 5 | import Category from "./category.class"; 6 | import ErrorCodes from "../../config/error.codes"; 7 | import SuccessCodes from "../../config/success.codes"; 8 | import * as httpStatus from "http-status"; 9 | import * as responses from "../../helpers/responses.handler"; 10 | 11 | const getCollection = () => { 12 | return MongoHelper.client 13 | .db(Config.DB_NAME) 14 | .collection(Config.CATEGORY_COLLECTION_NAME); 15 | }; 16 | 17 | export default class CategoryController { 18 | 19 | /** 20 | * Get all categories 21 | * URL [GET] / 22 | * 23 | * @param req 24 | * @param res 25 | */ 26 | public getAllCategories = async (req: Request, res: Response): Promise => { 27 | 28 | const collection = getCollection(); 29 | 30 | try { 31 | const result = await collection.find().toArray(); 32 | res 33 | .status(httpStatus.CREATED) 34 | .send({ 35 | success: true, 36 | data: result, 37 | message: SuccessCodes.SUCCESSFULLY_DATA_RETRIVED 38 | }) 39 | .end(); 40 | } catch (e) { 41 | res.send( 42 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 43 | ); 44 | } 45 | } 46 | 47 | /** 48 | * Get category by id 49 | * URL [GET] /:id 50 | * 51 | * @param req 52 | * @param res 53 | */ 54 | public getCategoryById = async (req: Request, res: Response): Promise => { 55 | 56 | const id = req.params.id; 57 | const collection = getCollection(); 58 | const filter = { _id: new ObjectId(id) }; 59 | 60 | try { 61 | const result = await collection.findOne(filter); 62 | 63 | if (!result) { 64 | res 65 | .status(httpStatus.NOT_FOUND) 66 | .send({}) 67 | .end(); 68 | } 69 | 70 | res 71 | .status(httpStatus.CREATED) 72 | .send(result) 73 | .end(); 74 | } catch (e) { 75 | res.send( 76 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 77 | ); 78 | } 79 | } 80 | 81 | /** 82 | * Create new category 83 | * URL [POST] /:id 84 | * 85 | * @param req 86 | * @param res 87 | */ 88 | public addCategory = async (req: Request, res: Response): Promise => { 89 | 90 | const requestData = req.body; 91 | const collection = getCollection(); 92 | const category = new Category(requestData); 93 | 94 | try { 95 | const result = await collection.insertOne(category); 96 | 97 | res 98 | .status(httpStatus.CREATED) 99 | .send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_ADDED)) 100 | .end(); 101 | } catch (e) { 102 | res.send( 103 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 104 | ); 105 | } 106 | } 107 | 108 | /** 109 | * Update a category 110 | * URL [POST] /:id 111 | * 112 | * @param req 113 | * @param res 114 | */ 115 | public updateCategory = async (req: Request, res: Response): Promise => { 116 | 117 | const requestData = req.body; 118 | const id = req.params.id; 119 | const filter = { _id: new ObjectId(id) }; 120 | const collection = getCollection(); 121 | 122 | requestData._id = filter._id; 123 | const category = new Category(requestData); 124 | 125 | try { 126 | const result = await collection.findOneAndUpdate(filter, category); 127 | 128 | res 129 | .status(httpStatus.CREATED) 130 | .send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_UPDATED)) 131 | .end(); 132 | } catch (e) { 133 | console.log(e) 134 | res.send( 135 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 136 | ); 137 | } 138 | } 139 | 140 | /** 141 | * Delete a category 142 | * URL [POST] /:id 143 | * 144 | * @param req 145 | * @param res 146 | */ 147 | public deleteCategory = async (req: Request, res: Response): Promise => { 148 | 149 | const id = req.params.id; 150 | const filter = { _id: new ObjectId(id) }; 151 | const collection = getCollection(); 152 | 153 | try { 154 | const result = await collection.deleteOne(filter); 155 | 156 | res 157 | .status(httpStatus.CREATED) 158 | .send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_DELETED)) 159 | .end(); 160 | } catch (e) { 161 | res.send( 162 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 163 | ); 164 | } 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/api/post/post.controller.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from "express"; 2 | import * as mongodb from "mongodb"; 3 | import { MongoHelper } from "../../config/mongodb.config"; 4 | import Post from "./post.class"; 5 | import Config from "../../config/config"; 6 | import ErrorCodes from "../../config/error.codes"; 7 | import SuccessCodes from "../../config/success.codes"; 8 | import * as httpStatus from "http-status"; 9 | import * as responses from "../../helpers/responses.handler"; 10 | import { ObjectId } from "mongodb"; 11 | 12 | const getCollection = () => { 13 | return MongoHelper.client 14 | .db(Config.DB_NAME) 15 | .collection(Config.POST_COLLECTION_NAME); 16 | }; 17 | 18 | export default class PostController { 19 | public addPost = async (req: Request, res: Response): Promise => { 20 | const requestData = req.body; 21 | const collection = getCollection(); 22 | 23 | requestData.createdDate = new Date().toString(); 24 | const post = new Post(requestData); 25 | try { 26 | await collection.insertOne(post); 27 | 28 | res 29 | .status(httpStatus.CREATED) 30 | .send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_ADDED)); 31 | res.end(); 32 | } catch (e) { 33 | console.error(e.message); 34 | res.send( 35 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 36 | ); 37 | } 38 | }; 39 | 40 | public getPost = async (req: Request, res: Response): Promise => { 41 | const collection = getCollection(); 42 | const id = req.params.id; 43 | try { 44 | const post = await collection.findOne({ 45 | _id: new ObjectId(id), 46 | }); 47 | 48 | res.send( 49 | responses.successWithPayload( 50 | SuccessCodes.SUCCESSFULLY_DATA_RETRIVED, 51 | post 52 | ) 53 | ); 54 | } catch (e) { 55 | console.error(e.message); 56 | res.send( 57 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 58 | ); 59 | } 60 | }; 61 | 62 | public getAllPost = async (req: Request, res: Response): Promise => { 63 | const collection: any = getCollection(); 64 | 65 | try { 66 | const data = await collection.find().toArray(); 67 | 68 | res.send( 69 | responses.successWithPayload( 70 | SuccessCodes.SUCCESSFULLY_DATA_RETRIVED, 71 | data 72 | ) 73 | ); 74 | } catch (e) { 75 | console.error(e.message); 76 | res.send( 77 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 78 | ); 79 | } 80 | }; 81 | 82 | public getPostsByUser = async (req: Request, res: Response): Promise => { 83 | const collection: any = getCollection(); 84 | 85 | try { 86 | const data = await collection.find({ userId: req.params.id }).toArray(); 87 | 88 | res.send( 89 | responses.successWithPayload( 90 | SuccessCodes.SUCCESSFULLY_DATA_RETRIVED, 91 | data 92 | ) 93 | ); 94 | } catch (e) { 95 | console.error(e.message); 96 | res.send( 97 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 98 | ); 99 | } 100 | }; 101 | 102 | public updatePost = async (req: Request, res: Response): Promise => { 103 | const { _id, userId, description, imageURL, createdDate, categoryName } = 104 | req.body; 105 | 106 | const collection: any = getCollection(); 107 | 108 | try { 109 | await collection.findOneAndUpdate( 110 | { _id: new mongodb.ObjectId(_id) }, 111 | { $set: { userId, description, imageURL, createdDate, categoryName } } 112 | ); 113 | 114 | res.send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_UPDATED)); 115 | } catch (e) { 116 | console.error(e.message); 117 | res.send( 118 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 119 | ); 120 | } 121 | }; 122 | 123 | public deletePost = async (req: Request, res: Response): Promise => { 124 | const id = req.params.id; 125 | const collection: any = getCollection(); 126 | 127 | try { 128 | await collection.deleteOne({ _id: new mongodb.ObjectId(id) }); 129 | res.send(responses.success(SuccessCodes.SUCCESSFULLY_DATA_DELETED)); 130 | } catch (e) { 131 | console.error(e.message); 132 | res.send( 133 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 134 | ); 135 | } 136 | }; 137 | 138 | public getAllPostsWithUsers = async ( 139 | req: Request, 140 | res: Response 141 | ): Promise => { 142 | try { 143 | const collection = getCollection(); 144 | 145 | const data = await collection 146 | .aggregate([ 147 | { 148 | $lookup: { 149 | from: "user", 150 | localField: "userId", 151 | foreignField: "uid", 152 | as: "user", 153 | }, 154 | }, 155 | { 156 | $unwind: "$user", 157 | }, 158 | ]) 159 | .toArray(); 160 | 161 | res.send( 162 | responses.successWithPayload( 163 | SuccessCodes.SUCCESSFULLY_DATA_RETRIVED, 164 | data 165 | ) 166 | ); 167 | } catch (e) { 168 | console.error(e.message); 169 | res.send( 170 | responses.failed(ErrorCodes.INTERNAL_ERROR, httpStatus.BAD_REQUEST) 171 | ); 172 | } 173 | }; 174 | } 175 | -------------------------------------------------------------------------------- /docs/er-diagram.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/postman/Code Kitty Prep API.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "35bdf8b3-3a95-45a2-a179-26d580f4959e", 4 | "name": "Code Kitty Prep API", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 6 | }, 7 | "item": [ 8 | { 9 | "name": "Posts", 10 | "item": [ 11 | { 12 | "name": "Delete Post", 13 | "request": { 14 | "method": "DELETE", 15 | "header": [], 16 | "body": { 17 | "mode": "raw", 18 | "raw": "", 19 | "options": { 20 | "raw": { 21 | "language": "json" 22 | } 23 | } 24 | }, 25 | "url": { 26 | "raw": "http://localhost:4000/api/v1/post/1", 27 | "protocol": "http", 28 | "host": [ 29 | "localhost" 30 | ], 31 | "port": "4000", 32 | "path": [ 33 | "api", 34 | "v1", 35 | "post", 36 | "1" 37 | ] 38 | } 39 | }, 40 | "response": [] 41 | }, 42 | { 43 | "name": "Add Post", 44 | "request": { 45 | "method": "POST", 46 | "header": [], 47 | "body": { 48 | "mode": "raw", 49 | "raw": "{\n \"description\": \"aaaa\",\n \"imageURL\": \"string\",\n \"createdDate\": \"string\",\n \"userId\": \"612211ba1cc1fa106465ca11\",\n \"categoryName\": \"string\"\n}", 50 | "options": { 51 | "raw": { 52 | "language": "json" 53 | } 54 | } 55 | }, 56 | "url": { 57 | "raw": "http://localhost:4000/api/v1/post", 58 | "protocol": "http", 59 | "host": [ 60 | "localhost" 61 | ], 62 | "port": "4000", 63 | "path": [ 64 | "api", 65 | "v1", 66 | "post" 67 | ] 68 | } 69 | }, 70 | "response": [] 71 | }, 72 | { 73 | "name": "Update Post", 74 | "request": { 75 | "method": "PUT", 76 | "header": [], 77 | "body": { 78 | "mode": "raw", 79 | "raw": "{\n \"_id\":\"\",\n \"description\": \"\",\n \"imageURL\": \"string\",\n \"createdDate\": \"string\",\n \"userId\": \"string\",\n \"categoryName\": \"string\"\n}", 80 | "options": { 81 | "raw": { 82 | "language": "json" 83 | } 84 | } 85 | }, 86 | "url": { 87 | "raw": "http://localhost:4000/api/v1/post", 88 | "protocol": "http", 89 | "host": [ 90 | "localhost" 91 | ], 92 | "port": "4000", 93 | "path": [ 94 | "api", 95 | "v1", 96 | "post" 97 | ] 98 | } 99 | }, 100 | "response": [] 101 | }, 102 | { 103 | "name": "Get All Posts", 104 | "protocolProfileBehavior": { 105 | "disableBodyPruning": true 106 | }, 107 | "request": { 108 | "method": "GET", 109 | "header": [], 110 | "body": { 111 | "mode": "raw", 112 | "raw": "{\n \"description\": \"\",\n \"imageURL\": \"string\",\n \"createdDate\": \"string\",\n \"userId\": \"string\",\n \"categoryName\": \"string\"\n}", 113 | "options": { 114 | "raw": { 115 | "language": "json" 116 | } 117 | } 118 | }, 119 | "url": { 120 | "raw": "http://localhost:4000/api/v1/post", 121 | "protocol": "http", 122 | "host": [ 123 | "localhost" 124 | ], 125 | "port": "4000", 126 | "path": [ 127 | "api", 128 | "v1", 129 | "post" 130 | ] 131 | } 132 | }, 133 | "response": [] 134 | }, 135 | { 136 | "name": "Get Post By Id", 137 | "protocolProfileBehavior": { 138 | "disableBodyPruning": true 139 | }, 140 | "request": { 141 | "method": "GET", 142 | "header": [], 143 | "body": { 144 | "mode": "raw", 145 | "raw": "{\n \"description\": \"\",\n \"imageURL\": \"string\",\n \"createdDate\": \"string\",\n \"userId\": \"string\",\n \"categoryName\": \"string\"\n}", 146 | "options": { 147 | "raw": { 148 | "language": "json" 149 | } 150 | } 151 | }, 152 | "url": { 153 | "raw": "http://localhost:4000/api/v1/post/1", 154 | "protocol": "http", 155 | "host": [ 156 | "localhost" 157 | ], 158 | "port": "4000", 159 | "path": [ 160 | "api", 161 | "v1", 162 | "post", 163 | "1" 164 | ] 165 | } 166 | }, 167 | "response": [] 168 | }, 169 | { 170 | "name": "Get Posts with Users", 171 | "request": { 172 | "method": "GET", 173 | "header": [], 174 | "url": { 175 | "raw": "http://localhost:4000/api/v1/post/users/all", 176 | "protocol": "http", 177 | "host": [ 178 | "localhost" 179 | ], 180 | "port": "4000", 181 | "path": [ 182 | "api", 183 | "v1", 184 | "post", 185 | "users", 186 | "all" 187 | ] 188 | } 189 | }, 190 | "response": [] 191 | } 192 | ] 193 | }, 194 | { 195 | "name": "Category", 196 | "item": [ 197 | { 198 | "name": "Add Category", 199 | "request": { 200 | "method": "POST", 201 | "header": [], 202 | "body": { 203 | "mode": "raw", 204 | "raw": "{\n \"name\": \"Care\"\n}", 205 | "options": { 206 | "raw": { 207 | "language": "json" 208 | } 209 | } 210 | }, 211 | "url": { 212 | "raw": "http://localhost:4000/api/v1/category", 213 | "protocol": "http", 214 | "host": [ 215 | "localhost" 216 | ], 217 | "port": "4000", 218 | "path": [ 219 | "api", 220 | "v1", 221 | "category" 222 | ] 223 | } 224 | }, 225 | "response": [] 226 | }, 227 | { 228 | "name": "Update Category", 229 | "request": { 230 | "method": "PUT", 231 | "header": [], 232 | "body": { 233 | "mode": "raw", 234 | "raw": "{\n \"_id\": \"\",\n \"name\": \"\"\n}", 235 | "options": { 236 | "raw": { 237 | "language": "json" 238 | } 239 | } 240 | }, 241 | "url": { 242 | "raw": "http://localhost:4000/api/v1/category", 243 | "protocol": "http", 244 | "host": [ 245 | "localhost" 246 | ], 247 | "port": "4000", 248 | "path": [ 249 | "api", 250 | "v1", 251 | "category" 252 | ] 253 | } 254 | }, 255 | "response": [] 256 | }, 257 | { 258 | "name": "Delete Category", 259 | "request": { 260 | "method": "DELETE", 261 | "header": [], 262 | "body": { 263 | "mode": "raw", 264 | "raw": "", 265 | "options": { 266 | "raw": { 267 | "language": "json" 268 | } 269 | } 270 | }, 271 | "url": { 272 | "raw": "http://localhost:4000/api/v1/category/1", 273 | "protocol": "http", 274 | "host": [ 275 | "localhost" 276 | ], 277 | "port": "4000", 278 | "path": [ 279 | "api", 280 | "v1", 281 | "category", 282 | "1" 283 | ] 284 | } 285 | }, 286 | "response": [] 287 | }, 288 | { 289 | "name": "Get Category By ID", 290 | "protocolProfileBehavior": { 291 | "disableBodyPruning": true 292 | }, 293 | "request": { 294 | "method": "GET", 295 | "header": [], 296 | "body": { 297 | "mode": "raw", 298 | "raw": "", 299 | "options": { 300 | "raw": { 301 | "language": "json" 302 | } 303 | } 304 | }, 305 | "url": { 306 | "raw": "http://localhost:4000/api/v1/category/1", 307 | "protocol": "http", 308 | "host": [ 309 | "localhost" 310 | ], 311 | "port": "4000", 312 | "path": [ 313 | "api", 314 | "v1", 315 | "category", 316 | "1" 317 | ] 318 | } 319 | }, 320 | "response": [] 321 | }, 322 | { 323 | "name": "Get All Categories", 324 | "protocolProfileBehavior": { 325 | "disableBodyPruning": true 326 | }, 327 | "request": { 328 | "method": "GET", 329 | "header": [], 330 | "body": { 331 | "mode": "raw", 332 | "raw": "", 333 | "options": { 334 | "raw": { 335 | "language": "json" 336 | } 337 | } 338 | }, 339 | "url": { 340 | "raw": "http://localhost:4000/api/v1/category", 341 | "protocol": "http", 342 | "host": [ 343 | "localhost" 344 | ], 345 | "port": "4000", 346 | "path": [ 347 | "api", 348 | "v1", 349 | "category" 350 | ] 351 | } 352 | }, 353 | "response": [] 354 | } 355 | ] 356 | }, 357 | { 358 | "name": "User", 359 | "item": [ 360 | { 361 | "name": "Create User", 362 | "request": { 363 | "method": "POST", 364 | "header": [], 365 | "body": { 366 | "mode": "raw", 367 | "raw": "{\n \"displayName\": \"Chamod Perera\",\n \"email\": \"hcsperera@gmail.com\",\n \"photoURL\": \"dsdsdsdsds\",\n \"uid\": \"dsdsdsd\"\n}", 368 | "options": { 369 | "raw": { 370 | "language": "json" 371 | } 372 | } 373 | }, 374 | "url": { 375 | "raw": "http://localhost:4000/api/v1/user", 376 | "protocol": "http", 377 | "host": [ 378 | "localhost" 379 | ], 380 | "port": "4000", 381 | "path": [ 382 | "api", 383 | "v1", 384 | "user" 385 | ] 386 | } 387 | }, 388 | "response": [] 389 | } 390 | ] 391 | } 392 | ], 393 | "variable": [ 394 | { 395 | "key": "url", 396 | "value": "url" 397 | } 398 | ] 399 | } --------------------------------------------------------------------------------