Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for knex template migration errors #244

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/knex/knexfile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_DATABASE } from './src/config';

export const dbConfig = {
const dbConfig = {
client: 'mysql',
connection: {
charset: 'utf8',
Expand All @@ -21,3 +21,5 @@ export const dbConfig = {
// stub: 'src/database/stubs',
},
};

export default dbConfig
6 changes: 2 additions & 4 deletions lib/knex/src/database/migrations/20210713110926_initial.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Knex } from 'knex';

const up = (knex: Knex): Promise<void> => {
export const up = (knex: Knex): Promise<void> => {
return knex.schema.createTable('users', table => {
table.bigIncrements('id').unsigned().primary();
table.string('email', 45).notNullable();
Expand All @@ -10,8 +10,6 @@ const up = (knex: Knex): Promise<void> => {
});
};

const down = (knex: Knex): Promise<void> => {
export const down = (knex: Knex): Promise<void> => {
return knex.schema.dropTable('users');
};

export default { up, down };
4 changes: 2 additions & 2 deletions lib/mikro-orm/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class AuthRoute implements Routes {
}

private initializeRoutes() {
this.router.post(`${this.path}signup`, ValidationMiddleware(CreateUserDto, 'body'), this.auth.signUp);
this.router.post(`${this.path}login`, ValidationMiddleware(CreateUserDto, 'body'), this.auth.logIn);
this.router.post(`${this.path}signup`, ValidationMiddleware(CreateUserDto), this.auth.signUp);
this.router.post(`${this.path}login`, ValidationMiddleware(CreateUserDto), this.auth.logIn);
this.router.post(`${this.path}logout`, AuthMiddleware, this.auth.logOut);
}
}
4 changes: 2 additions & 2 deletions lib/mikro-orm/src/routes/users.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class UserRoute implements Routes {
private initializeRoutes() {
this.router.get(`${this.path}`, this.user.getUsers);
this.router.get(`${this.path}/:id`, this.user.getUserById);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto, 'body'), this.user.createUser);
this.router.put(`${this.path}/:id`, ValidationMiddleware(CreateUserDto, 'body', true), this.user.updateUser);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto), this.user.createUser);
this.router.put(`${this.path}/:id`, ValidationMiddleware(CreateUserDto, true), this.user.updateUser);
this.router.delete(`${this.path}/:id`, this.user.deleteUser);
}
}
4 changes: 2 additions & 2 deletions lib/mongoose/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class AuthRoute implements Routes {
}

private initializeRoutes() {
this.router.post(`${this.path}signup`, ValidationMiddleware(CreateUserDto, 'body'), this.auth.signUp);
this.router.post(`${this.path}login`, ValidationMiddleware(CreateUserDto, 'body'), this.auth.logIn);
this.router.post(`${this.path}signup`, ValidationMiddleware(CreateUserDto), this.auth.signUp);
this.router.post(`${this.path}login`, ValidationMiddleware(CreateUserDto), this.auth.logIn);
this.router.post(`${this.path}logout`, AuthMiddleware, this.auth.logOut);
}
}
4 changes: 2 additions & 2 deletions lib/mongoose/src/routes/users.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class UserRoute implements Routes {
private initializeRoutes() {
this.router.get(`${this.path}`, this.user.getUsers);
this.router.get(`${this.path}/:id`, this.user.getUserById);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto, 'body'), this.user.createUser);
this.router.put(`${this.path}/:id`, ValidationMiddleware(CreateUserDto, 'body', true), this.user.updateUser);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto), this.user.createUser);
this.router.put(`${this.path}/:id`, ValidationMiddleware(CreateUserDto, true), this.user.updateUser);
this.router.delete(`${this.path}/:id`, this.user.deleteUser);
}
}
4 changes: 2 additions & 2 deletions lib/prisma/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class AuthRoute implements Routes {
}

private initializeRoutes() {
this.router.post(`${this.path}signup`, ValidationMiddleware(CreateUserDto, 'body'), this.auth.signUp);
this.router.post(`${this.path}login`, ValidationMiddleware(CreateUserDto, 'body'), this.auth.logIn);
this.router.post(`${this.path}signup`, ValidationMiddleware(CreateUserDto), this.auth.signUp);
this.router.post(`${this.path}login`, ValidationMiddleware(CreateUserDto), this.auth.logIn);
this.router.post(`${this.path}logout`, AuthMiddleware, this.auth.logOut);
}
}
4 changes: 2 additions & 2 deletions lib/prisma/src/routes/users.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class UserRoute implements Routes {
private initializeRoutes() {
this.router.get(`${this.path}`, this.user.getUsers);
this.router.get(`${this.path}/:id(\\d+)`, this.user.getUserById);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto, 'body'), this.user.createUser);
this.router.put(`${this.path}/:id(\\d+)`, ValidationMiddleware(CreateUserDto, 'body', true), this.user.updateUser);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto), this.user.createUser);
this.router.put(`${this.path}/:id(\\d+)`, ValidationMiddleware(CreateUserDto, true), this.user.updateUser);
this.router.delete(`${this.path}/:id(\\d+)`, this.user.deleteUser);
}
}
2 changes: 1 addition & 1 deletion lib/routing-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "swc src -d dist --source-maps --copy-files",
"build:tsc": "tsc && tsc-alias",
"test": "jest --forceExit --detectOpenHandles",
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
"lint": "eslint --ignore-path .gitignore --ext .ts src",
"lint:fix": "npm run lint -- --fix",
"deploy:prod": "npm run build && pm2 start ecosystem.config.js --only prod",
"deploy:dev": "pm2 start ecosystem.config.js --only dev"
Expand Down
4 changes: 2 additions & 2 deletions lib/routing-controllers/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export class AuthController {
public auth = Container.get(AuthService);

@Post('/signup')
@UseBefore(ValidationMiddleware(CreateUserDto, 'body'))
@UseBefore(ValidationMiddleware(CreateUserDto))
@HttpCode(201)
async signUp(@Body() userData: User) {
const signUpUserData: User = await this.auth.signup(userData);
return { data: signUpUserData, message: 'signup' };
}

@Post('/login')
@UseBefore(ValidationMiddleware(CreateUserDto, 'body'))
@UseBefore(ValidationMiddleware(CreateUserDto))
async logIn(@Res() res: Response, @Body() userData: User) {
const { cookie, findUser } = await this.auth.login(userData);

Expand Down
4 changes: 2 additions & 2 deletions lib/routing-controllers/src/controllers/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export class UserController {

@Post('/users')
@HttpCode(201)
@UseBefore(ValidationMiddleware(CreateUserDto, 'body'))
@UseBefore(ValidationMiddleware(CreateUserDto))
@OpenAPI({ summary: 'Create a new user' })
async createUser(@Body() userData: User) {
const createUserData: User = await this.user.createUser(userData);
return { data: createUserData, message: 'created' };
}

@Put('/users/:id')
@UseBefore(ValidationMiddleware(CreateUserDto, 'body', true))
@UseBefore(ValidationMiddleware(CreateUserDto, true))
@OpenAPI({ summary: 'Update a user' })
async updateUser(@Param('id') userId: number, @Body() userData: User) {
const updateUserData: User[] = await this.user.updateUser(userId, userData);
Expand Down
4 changes: 2 additions & 2 deletions lib/sequelize/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class AuthRoute implements Routes {
}

private initializeRoutes() {
this.router.post('/signup', ValidationMiddleware(CreateUserDto, 'body'), this.auth.signUp);
this.router.post('/login', ValidationMiddleware(CreateUserDto, 'body'), this.auth.logIn);
this.router.post('/signup', ValidationMiddleware(CreateUserDto), this.auth.signUp);
this.router.post('/login', ValidationMiddleware(CreateUserDto), this.auth.logIn);
this.router.post('/logout', AuthMiddleware, this.auth.logOut);
}
}
4 changes: 2 additions & 2 deletions lib/sequelize/src/routes/users.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class UserRoute implements Routes {
private initializeRoutes() {
this.router.get(`${this.path}`, this.user.getUsers);
this.router.get(`${this.path}/:id(\\d+)`, this.user.getUserById);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto, 'body'), this.user.createUser);
this.router.put(`${this.path}/:id(\\d+)`, ValidationMiddleware(CreateUserDto, 'body', true), this.user.updateUser);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto), this.user.createUser);
this.router.put(`${this.path}/:id(\\d+)`, ValidationMiddleware(CreateUserDto, true), this.user.updateUser);
this.router.delete(`${this.path}/:id(\\d+)`, this.user.deleteUser);
}
}
4 changes: 2 additions & 2 deletions lib/typegoose/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class AuthRoute implements Routes {
}

private initializeRoutes() {
this.router.post('/signup', ValidationMiddleware(CreateUserDto, 'body'), this.auth.signUp);
this.router.post('/login', ValidationMiddleware(CreateUserDto, 'body'), this.auth.logIn);
this.router.post('/signup', ValidationMiddleware(CreateUserDto), this.auth.signUp);
this.router.post('/login', ValidationMiddleware(CreateUserDto), this.auth.logIn);
this.router.post('/logout', AuthMiddleware, this.auth.logOut);
}
}
4 changes: 2 additions & 2 deletions lib/typegoose/src/routes/users.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class UserRoute implements Routes {
private initializeRoutes() {
this.router.get(`${this.path}`, this.user.getUsers);
this.router.get(`${this.path}/:id`, this.user.getUserById);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto, 'body'), this.user.createUser);
this.router.put(`${this.path}/:id`, ValidationMiddleware(CreateUserDto, 'body', true), this.user.updateUser);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto), this.user.createUser);
this.router.put(`${this.path}/:id`, ValidationMiddleware(CreateUserDto, true), this.user.updateUser);
this.router.delete(`${this.path}/:id`, this.user.deleteUser);
}
}
4 changes: 2 additions & 2 deletions lib/typeorm/src/routes/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class AuthRoute implements Routes {
}

private initializeRoutes() {
this.router.post('/signup', ValidationMiddleware(CreateUserDto, 'body'), this.auth.signUp);
this.router.post('/login', ValidationMiddleware(CreateUserDto, 'body'), this.auth.logIn);
this.router.post('/signup', ValidationMiddleware(CreateUserDto), this.auth.signUp);
this.router.post('/login', ValidationMiddleware(CreateUserDto), this.auth.logIn);
this.router.post('/logout', AuthMiddleware, this.auth.logOut);
}
}
4 changes: 2 additions & 2 deletions lib/typeorm/src/routes/users.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class UserRoute implements Routes {
private initializeRoutes() {
this.router.get(`${this.path}`, this.user.getUsers);
this.router.get(`${this.path}/:id(\\d+)`, this.user.getUserById);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto, 'body'), this.user.createUser);
this.router.put(`${this.path}/:id(\\d+)`, ValidationMiddleware(CreateUserDto, 'body', true), this.user.updateUser);
this.router.post(`${this.path}`, ValidationMiddleware(CreateUserDto), this.user.createUser);
this.router.put(`${this.path}/:id(\\d+)`, ValidationMiddleware(CreateUserDto, true), this.user.updateUser);
this.router.delete(`${this.path}/:id(\\d+)`, this.user.deleteUser);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-express-starter",
"version": "10.1.1",
"version": "10.2.1",
"description": "Quick and Easy TypeScript Express Starter",
"author": "AGUMON <[email protected]>",
"license": "MIT",
Expand Down