Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor committed Aug 5, 2022
1 parent fe41e69 commit 4b06d33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ RUN npm run build

FROM node:16-alpine as production

# ARG NODE_ENV=production
# ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY --from=build /usr/src/app/dist ./dist
# COPY .env ./

# ENV PORT 3000
# EXPOSE ${PORT}

CMD [ "node", "dist/src/app.js" ]
6 changes: 3 additions & 3 deletions tests/user.test.ts → src/tests/user.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import mongoose from 'mongoose';
import request from 'supertest';

import app from '../src/app';
import * as authService from '../src/user/services/authService';
import app from '../app';
import * as authService from '../user/services/authService';

const userId = new mongoose.Types.ObjectId().toString();
const userPayload = {
Expand Down Expand Up @@ -58,5 +58,5 @@ describe('User Test', () => {
// the email and password gets validation
// verify that the handler handles any errors

// Create a user session
// login user
});
9 changes: 5 additions & 4 deletions src/user/controllers/authController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { NextFunction, Request, Response } from 'express';
import * as _ from 'lodash';
import { omit } from 'lodash';
import { configuration } from '../../../config/default';

import logger from '../../logger';
import catchAsync from '../../utils/catchAsync';
Expand All @@ -12,7 +10,10 @@ import { login, signup } from '../services/authService';
export const userSignup = catchAsync(
async (req: Request, res: Response, next: NextFunction): Promise<void> => {
const { name, email, password }: User = req.body;
const isAdmin: boolean = _.isBoolean(req.query.admin);
const { admin } = req.query;

const isAdmin = (admin as string).toLowerCase() === 'false' ? false : true;

const payload = {
name,
email,
Expand All @@ -22,7 +23,7 @@ export const userSignup = catchAsync(
await signup(payload, isAdmin);

res.status(201).json({
message: 'User signup successful',
message: isAdmin ? 'Admin signup successful' : 'User signup successful',
status: 'success',
});
}
Expand Down

0 comments on commit 4b06d33

Please sign in to comment.