You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Controller:
import { IsNotEmpty } from 'class-validator';
import { Body, JsonController, Post, Req, Res } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Logger, LoggerInterface } from '../../decorators/Logger';
import { AuthService } from '../services/AuthService';
// import { UserService } from '../services/UserService';
import { UserResponse } from './UserController';
class LoginBody { @isnotempty()
public username: string;
Middleware:
import jwt from 'jsonwebtoken';
import { ExpressMiddlewareInterface, Middleware } from 'routing-controllers';
import { Logger, LoggerInterface } from '../../decorators/Logger';
@Middleware({ type: 'before' })
export class JwtAuthMiddleware implements ExpressMiddlewareInterface {
}
Controller:
import { IsNotEmpty } from 'class-validator';
import { Body, JsonController, Post, Req, Res } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { Logger, LoggerInterface } from '../../decorators/Logger';
import { AuthService } from '../services/AuthService';
// import { UserService } from '../services/UserService';
import { UserResponse } from './UserController';
class LoginBody {
@isnotempty()
public username: string;
}
@jsoncontroller('/auth')
@openapi({ security: [{ basicAuth: [] }] })
export class AuthController {
}
Service
import bcrypt from 'bcrypt';
import jwt from 'jsonwebtoken';
import { Service } from 'typedi';
import { Logger, LoggerInterface } from '../../decorators/Logger';
import { User } from '../models/User';
import { UserService } from './UserService';
@service()
export class AuthService {
}
Repository
import knex, { Knex } from 'knex';
import { EntityRepository, Repository } from 'typeorm';
import knexConfig from '../../../src/knexfile';
import { User } from '../models/User';
const environment = process.env.NODE_ENV || 'development';
const DB: Knex = knex(knexConfig[environment]);
@entityrepository(User)
export class UserRepository extends Repository {
public async findOneByUsername(username: string): Promise<User | undefined> {
const user = await DB('user')
.where({ username })
.first();
}
But I always failed
The text was updated successfully, but these errors were encountered: