Skip to content

Commit 148e91d

Browse files
switch to ES6 syntax
1 parent ae58c91 commit 148e91d

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Week3/todo backend/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
package-lock.json
2-
secrets.json
2+
secrets.js

Week3/todo backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6+
"type": "module",
67
"scripts": {
78
"dev": "nodemon server.js"
89
},
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{
1+
export default {
22
"mongoConnection": "",
3-
"test": ""
43
}

Week3/todo backend/server.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
const express = require('express');
2-
const bodyParser = require('body-parser')
1+
import express from 'express';
2+
import bodyParser from 'body-parser';
33
const app = express();
4-
const ObjectID = require('mongodb').ObjectID;
5-
const MongoClient = require('mongodb').MongoClient
6-
const config = require('./secrets.json');
4+
import * as mongodb from 'mongodb';
5+
import config from './secrets.js';
76

87
async function getMongoCollection() {
9-
const client = new MongoClient(config.mongoConnection);
8+
const client = new mongodb.MongoClient(config.mongoConnection);
109
await client.connect();
1110
const database = client.db("todo-app");
1211
return database.collection("todos");

0 commit comments

Comments
 (0)