Skip to content

Commit

Permalink
correcting minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
enyichiaagu committed Sep 5, 2024
1 parent 4f8ae39 commit 0ea2938
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion data/model.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DatabaseSync } from 'node:sqlite';
import { nanoid } from 'nanoid';

const database = new DatabaseSync(`${import.meta.dirname}/main.db`);

Expand Down
8 changes: 4 additions & 4 deletions routes/todos.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import {
deleteTodo,
} from '../data/queries.js';

// No real login implementation will be used, this is only for the purpose of illustration

const todosRouter = express.Router();

// Use this to simulate a logged in user
const defaultUserId = 'CHANGE TO VALID USER ID STRING';

// Create a todo as a user
Expand All @@ -33,7 +32,7 @@ todosRouter.post('/', (req, res) => {
todoId,
title,
checked: Boolean(addedTodo.checked),
joined: new Date(addedTodo.created_at).toISOString(),
createdAt: new Date(addedTodo.created_at).toISOString(),
});
});

Expand Down Expand Up @@ -83,7 +82,7 @@ todosRouter.patch('/:id', (req, res) => {
);

return res.status(200).json({
message: 'Successfully updated Todo',
message: 'Successfully checked todo',
update: {
todoId: todo_id,
title,
Expand All @@ -94,6 +93,7 @@ todosRouter.patch('/:id', (req, res) => {
});
});

// Delete a todo by ID
todosRouter.delete('/:id', (req, res) => {
const todoId = req.params.id;

Expand Down
1 change: 1 addition & 0 deletions routes/users.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ usersRouter.post('/', async (req, res) => {
});
});

// No real login implementation will be used, this is only for the purpose of illustration
usersRouter.post('/session', async (req, res) => {
const { username, password } = req.body;

Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ app.use(express.json());
app.use('/api/users', usersRouter);
app.use('/api/todos', todosRouter);

app.listen(PORT, () => console.log('Listening'));
app.listen(PORT, () => console.log(`Listening on PORT ${PORT}`));

0 comments on commit 0ea2938

Please sign in to comment.