Skip to content

Commit

Permalink
Merge pull request #13 from Devvyky/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
Devvyky authored Aug 5, 2022
2 parents fe41e69 + e4d8ac5 commit da36fbf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 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" ]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

# League API

A small project that allow admins to creat teams, fixtures, etc

A small project that allow admins to create teams, fixtures, etc

## Run Locally

Expand Down Expand Up @@ -30,7 +28,6 @@ Start the server
npm run start
```


## Environment Variables

Create a `.env` file and replace the contents of `example.env` inside your `.env` file
Expand All @@ -43,3 +40,6 @@ To run tests, run the following command
npm run test
```

## Documentation

[Documentation](https://documenter.getpostman.com/view/9742220/VUjLLSoa)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "npm run build && node dist/src/app.js",
"dev": "NODE_ENV=development nodemon src/app.ts",
"build": "rimraf ./dist && tsc -p .",
"test": "jest --watch"
"test": "jest --watchAll"
},
"author": "",
"license": "ISC",
Expand Down
9 changes: 2 additions & 7 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const app: Application = express();
let RedisStore = connectRedis(session);
const redisClient = new Redis(configuration().redis.url);

// if running behind a proxy
// app.set('trust proxy', 1)

// Set Security Headers
app.use(helmet());

Expand Down Expand Up @@ -55,10 +52,9 @@ app.use(
resave: false,
saveUninitialized: false,
cookie: {
secure: configuration().env === 'production' ? true : 'auto',
secure: configuration().env === 'staging' ? true : 'auto',
httpOnly: true,
// expires:
sameSite: configuration().env === 'production' ? 'none' : 'lax',
sameSite: configuration().env === 'staging' ? 'none' : 'lax',
},
})
);
Expand Down Expand Up @@ -89,7 +85,6 @@ app.listen(port, async () => {
});

app.all('*', (req, res, next) => {
configuration().env;
next(new AppError(`Can't find ${req.originalUrl} on this server`, 404));
});

Expand Down
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 da36fbf

Please sign in to comment.