diff --git a/package-lock.json b/package-lock.json index 4d782cc..ce97ce0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -232,6 +232,12 @@ "@types/node": "*" } }, + "@types/uuid": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==", + "dev": true + }, "@types/webidl-conversions": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz", @@ -2230,6 +2236,11 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index 5c42d15..24762ff 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "job-portal", + "name": "anamnesis", "version": "1.0.0", - "description": "job portal backend node app", + "description": "anamnesis backend ExpressTS app", "main": "dist/index.js", "scripts": { "start": "nodemon src/index.ts && tsc && node dist/src/index.js" @@ -19,7 +19,8 @@ "mongodb": "^4.1.2", "nodemon": "^2.0.12", "passport": "^0.5.0", - "passport-jwt": "^4.0.0" + "passport-jwt": "^4.0.0", + "uuid": "^8.3.2" }, "devDependencies": { "@types/bcrypt": "^5.0.0", @@ -29,6 +30,7 @@ "@types/node": "^16.9.4", "@types/passport": "^1.0.7", "@types/passport-jwt": "^3.0.6", + "@types/uuid": "^8.3.1", "tslint": "^6.1.3", "typescript": "^4.4.3" } diff --git a/src/authentication/routes.ts b/src/authentication/routes.ts index 9a2188d..71e038e 100644 --- a/src/authentication/routes.ts +++ b/src/authentication/routes.ts @@ -3,19 +3,26 @@ import { DB_NAME, getDatabaseClient } from '../db-utils'; import bcrypt from 'bcrypt'; import { generateJWT, SALT_ROUNDS } from './auth'; import sendGridMail, { MailDataRequired } from '@sendgrid/mail'; +import { Category } from '../models/category'; +import { Shelf } from '..//models/shelf'; +import { v4 as uuidv4 } from 'uuid'; const authRoutes = express.Router(); -authRoutes.get('/users/', async (request, response) => { - response.send("List of users will be displayed"); -}); - authRoutes.post('/register-applicant/', async (request, response) => { const name: string = request.body.name; const email: string = request.body.email; const password: string = request.body.password; - const userType: string = 'APPLICANT'; const isVerified: boolean = false; + const categories: Array = []; + const uncategorised: Shelf = { + _id: uuidv4(), + name: 'Uncategorised', + description: '', + viewType: 'PRIVATE', + isArchived: false, + addedWords: [] + } const userCollection = getDatabaseClient().db(DB_NAME).collection('users'); @@ -52,7 +59,8 @@ authRoutes.post('/register-applicant/', async (request, response) => { email, password: hashedPassword, isVerified, - userType, + categories, + uncategorised }); }); @@ -112,7 +120,7 @@ authRoutes.post('/request-verification/', async (request, response) => { sendGridMail.send(otpMail).then(data=> { response.send('Verification OTP sent'); return; - }, (err) => { + }, () => { response.sendStatus(500); response.send("SMTP system failure"); return; diff --git a/src/models/user.ts b/src/models/user.ts index ffaff53..bd0f206 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -1,4 +1,5 @@ import { Category } from "./category"; +import { Shelf } from "./shelf"; export type IUser = { _id: string, @@ -8,4 +9,5 @@ export type IUser = { isVerified: boolean, otp: number, categories: Array, + uncategorised: Shelf, } \ No newline at end of file