Commit a937fef0 authored by root's avatar root
Browse files

Initial commit

parent d048871f
const fs = require("fs");
const path = require('path');
const readUsers = () => {
let rawdata = fs.readFileSync(path.join(process.cwd(), 'db/user.json'), 'utf8');
if(!rawdata)
return [];
return JSON.parse(rawdata);
}
const writeUsers = async (data) => {
fs.writeFileSync(path.join(process.cwd(), 'db/user.json'), JSON.stringify(data), 'utf8');
}
module.exports = {
readUsers,
writeUsers
}
\ No newline at end of file
......@@ -5,14 +5,6 @@ const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.post("/login", (req, res) => {
console.log("body: ", req.body);
res.send('Hello from API');
})
app.get("/detail", (req, res) => {
res.send('DEEEEETAIL');
})
app.use(require('./routes'))
app.listen(3001, () => console.log('App available on http://localhost/3001'));
const express = require('express');
var router = express.Router();
router.post("/login", (req, res) => {
const {email, password} = req.body;
const result = login(email, password);
// console.log("body: ", req.body);
// res.json({name: "test"});
})
router.post("/register", (req, res) => {
res.send('DEEEEETAIL');
})
module.exports = router;
\ No newline at end of file
const login = (email, password) => {
const users = readUsers();
return "login return"
}
module.exports = {
login
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment