diff --git a/src/index.ts b/src/index.ts index af4f248..3976c92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,3 +6,13 @@ const app = createApp(); const server = app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); }); + +function shutdown(signal: string) { + console.log(`${signal} received — shutting down...`); + server.close(() => { + console.log('All connections closed. Exiting.'); + process.exit(0); + }); +} +process.on('SIGTERM', () => shutdown('SIGTERM')); +process.on('SIGINT', () => shutdown('SIGINT')); \ No newline at end of file diff --git a/src/repositories/userRepository.ts b/src/repositories/userRepository.ts index 223801b..608679f 100644 --- a/src/repositories/userRepository.ts +++ b/src/repositories/userRepository.ts @@ -1,5 +1,5 @@ import { User, CreateUserDto, UpdateUserDto } from '../models/User'; -// In-memory store — replace with DB client in a real app + const store: User[] = []; let nextId = 1; export const userRepository = {