Only warning now... Green pipeline?
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
12
lib/app.ts
12
lib/app.ts
@@ -1,8 +1,8 @@
|
||||
import koa from 'koa';
|
||||
import koaBodyparser from 'koa-bodyparser';
|
||||
import koaCookie from 'koa-cookie';
|
||||
import koaPassport from 'koa-passport';
|
||||
import koaSession from 'koa-session';
|
||||
import Koa from 'koa';
|
||||
import bodyparser from 'koa-bodyparser';
|
||||
import cookie from 'koa-cookie';
|
||||
import passport from 'koa-passport';
|
||||
import session from 'koa-session';
|
||||
|
||||
import { performanceLogger, perfromanceTimer } from './middleware/performance';
|
||||
import { errorHandler } from './middleware/errorHandler';
|
||||
@@ -12,7 +12,7 @@ const app: Koa = new Koa();
|
||||
app.use(errorHandler);
|
||||
app.use(perfromanceTimer);
|
||||
app.use(performanceLogger);
|
||||
app.use(bodyParser());
|
||||
app.use(bodyparser());
|
||||
app.use(cookie());
|
||||
|
||||
app.keys = [process.env.SESSION_KEYS as string];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import koaPassport from 'koa-passport';
|
||||
// import koaPassport from 'koa-passport';
|
||||
|
||||
// import Users from 'grow-db/lib/models/users';
|
||||
// import { User } from 'grow-db/lib/schemas/user';
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { Next } from 'koa';
|
||||
import { KoaContext } from '../types/KoaContext';
|
||||
import { Context, Next } from 'koa';
|
||||
|
||||
export const performanceLogger = async (ctx: KoaContext, next: Next) => {
|
||||
export const performanceLogger = async (ctx: Context, next: Next) => {
|
||||
await next();
|
||||
const rt = ctx.response.get('X-Response-Time');
|
||||
console.log(`${ctx.method} ${ctx.url} - ${rt}`);
|
||||
};
|
||||
|
||||
export const perfromanceTimer = async (ctx: KoaContext, next: Next) => {
|
||||
export const perfromanceTimer = async (ctx: Context, next: Next) => {
|
||||
const start = Date.now();
|
||||
await next();
|
||||
const ms = Date.now() - start;
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface AuthMethods {
|
||||
setPassword(password: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface AuthModel extends Model<AuthPrivate, {}, AuthMethods> {
|
||||
export interface AuthModel extends Model<AuthPrivate, void, AuthMethods> {
|
||||
authenticate(password: any): boolean;
|
||||
findByUsername(username: string): Promise<AuthModel & AuthPrivate>;
|
||||
isUsernameAvailable(username: string): Promise<boolean>;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import koaPassport from 'koa-passport';
|
||||
import { Strategy } from 'passport-local';
|
||||
import passport from 'koa-passport';
|
||||
import { Strategy as LocalStrategy } from 'passport-local';
|
||||
|
||||
import Auth from '../model/auth';
|
||||
|
||||
export const localStrategy = passport.use(
|
||||
new Strategy(async (username, password, done) => {
|
||||
new LocalStrategy(async (username, password, done) => {
|
||||
const user = await Auth.findOne({
|
||||
where: {
|
||||
username,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import auth from '../model/auth';
|
||||
import Auth from '../model/auth';
|
||||
import { AuthModel, AuthPrivate } from '../schema/auth';
|
||||
import { sign } from './jwt';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user