
- Replace FastAPI with Express.js framework - Replace SQLAlchemy with Sequelize ORM - Replace Alembic with Sequelize migrations - Implement bcryptjs for password hashing - Add JWT authentication with jsonwebtoken - Create Express routes and controllers - Add input validation with express-validator - Implement rate limiting and security headers - Configure CORS for all origins - Add environment-based configuration - Update README with Node.js setup instructions Environment variables required: - JWT_SECRET: JWT secret key for token signing - NODE_ENV: Environment (development/production) - PORT: Server port (default: 3000) - JWT_EXPIRES_IN: Token expiration time (default: 24h)
22 lines
534 B
JavaScript
22 lines
534 B
JavaScript
const { Sequelize } = require('sequelize');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const dbDir = '/app/storage/db';
|
|
if (!fs.existsSync(dbDir)) {
|
|
fs.mkdirSync(dbDir, { recursive: true });
|
|
}
|
|
|
|
const sequelize = new Sequelize({
|
|
dialect: 'sqlite',
|
|
storage: path.join(dbDir, 'db.sqlite'),
|
|
logging: process.env.NODE_ENV === 'development' ? console.log : false,
|
|
define: {
|
|
timestamps: true,
|
|
underscored: true,
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at'
|
|
}
|
|
});
|
|
|
|
module.exports = { sequelize }; |