Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit ea5cb65

Browse files
committed
comment most of the user routes, comment sentry, api loads now
1 parent 7c5bb9f commit ea5cb65

File tree

15 files changed

+257
-248
lines changed

15 files changed

+257
-248
lines changed

packages/shared-types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './user'
2-
export * from './auth'
1+
export * from './auth'
2+
export * from './user'

services/api/jest.integration.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Config } from '@jest/types'
2+
23
import globalConfig from './jest.config';
34

45
const config: Config.InitialOptions = {

services/api/jest.unit.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Config } from '@jest/types'
2+
23
import globalConfig from './jest.config';
34

45
const config: Config.InitialOptions = {

services/api/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'reflect-metadata'
22

33
import cors from '@koa/cors'
4+
import { Server } from 'http'
45
import Koa from 'koa'
56
import bodyParser from 'koa-bodyparser'
67
import helmet from 'koa-helmet'
@@ -11,7 +12,6 @@ import { config } from './config'
1112
import { errorHandler, logger, tracingHandler } from './middleware'
1213
import { protectedRouter } from './protectedRoutes'
1314
import { unprotectedRouter } from './unprotectedRoutes'
14-
import { Server } from 'http'
1515

1616
let server: Server;
1717
export default () : Server => {

services/api/src/controller/auth.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { User, LoginResponse } from '@launchpad-ts/shared-types'
2-
import { UserEntity, userSchema } from '../entity/user'
1+
import { LoginResponse,User } from '@launchpad-ts/shared-types'
32
import {
3+
body,
4+
Context,
45
request,
56
responsesAll,
67
summary,
78
swaggerClass,
89
swaggerProperty,
910
tagsAll,
10-
body,
11-
Context,
1211
} from 'koa-swagger-decorator'
1312
import { getManager } from 'typeorm'
14-
import passwordHelper from '../helper/password'
13+
14+
import { UserEntity, userSchema } from '../entity/user'
1515
import jwtHelper from '../helper/jwt'
16+
import passwordHelper from '../helper/password'
1617

1718
@swaggerClass()
1819
export class LoginRequest {
@@ -56,14 +57,15 @@ export default class UserController {
5657
public static async login(ctx: Context): Promise<void> {
5758
const userRepository = getManager().getRepository(UserEntity)
5859
const body = ctx.request.body
60+
const { email, password } = body as { email: string, password: string };
5961

6062
const [user]: User[] = await userRepository.find({
61-
where: { email: body.email },
63+
where: { email: email },
6264
})
6365
const valid =
64-
user && (await passwordHelper.validatePassword(user, body.password))
66+
user && (await passwordHelper.validatePassword(user, password))
6567
if (valid) {
66-
const { password, ...userWithoutPassword } = user
68+
const { ...userWithoutPassword } = user
6769
const accessToken = jwtHelper.getAccessToken(user);
6870
ctx.status = 200
6971
ctx.body = <LoginResponse>{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1+
export { default as auth } from './auth'
12
export { default as health } from './health'
23
export { default as user } from './user'
3-
export { default as auth } from './auth'

0 commit comments

Comments
 (0)