This commit is contained in:
2024-04-30 00:50:27 +02:00
parent ff8cc4cccf
commit dc1b955a8a
6 changed files with 90 additions and 11 deletions

View File

@ -1,5 +1,5 @@
import { Request, Response } from "express";
export function login_post(req: Request, res: Response) {
export function signup_post(req: Request, res: Response) {
res.send("logged in");
}

View File

@ -8,7 +8,7 @@ const router = Router();
//const mws = [requireAuth, handleValidation.handleValidationError];
router.post("/login", authController.login_post);
router.post("/signup", authController.signup_post);
//router.post(
// "/login",

View File

@ -0,0 +1,48 @@
import { Sequelize } from 'sequelize';
let sequelize: Sequelize | null = null;
const connectDB = async () => {
sequelize = new Sequelize({
dialect: 'mariadb',
host: 'localhost',
username: 'your_username',
password: 'your_password',
database: 'your_database',
});
try {
await sequelize.authenticate();
console.log('Connection to the database has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
};
const dropDB = async () => {
if (sequelize) {
try {
await sequelize.drop();
console.log('Database dropped successfully.');
} catch (error) {
console.error('Error dropping database:', error);
} finally {
await sequelize.close();
}
}
};
const dropTables = async () => {
if (sequelize) {
try {
await sequelize.sync({ force: true });
console.log('All tables dropped successfully.');
} catch (error) {
console.error('Error dropping tables:', error);
} finally {
await sequelize.close();
}
}
};
export { connectDB, dropDB, dropTables };