Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Log system is complated!!
Browse files Browse the repository at this point in the history
  • Loading branch information
yuito-it committed Jul 31, 2023
1 parent 84fca32 commit 6d356af
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 21 deletions.
17 changes: 12 additions & 5 deletions conf/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ const deta = Deta();
const db = deta.Base('log-conf');

/* GET users listing. */
router.get('/', function (req, res, next) {
router.get('/', async function (req, res, next) {
console.log("GET!!");
try {
var data = db.get("status");
const data = await db.get("status");
console.log(data);
res.status(200).json(data);
}
catch (err) {
res.status(500).json(err);
console.log(err);
throw err;
}
});
router.post('/', (req, res, next) => {
try{
db.put(req.body,"status");
console.log(req.body);
try {
db.put(req.body, "status");
console.log("putting!!");
console.log(req.body);
res.status(200).json(req.body);
}
catch(err){
catch (err) {
res.status(500).json(err);
throw err;
}
Expand Down
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ const db = deta.Base('log-conf');

const port = process.env.PORT || 8080;

const bodyParser = require('body-parser');
const express = require('express');
const app = express();

app.use(bodyParser.json());
app.use(express.json());

const status = require('./conf/status.js');
app.use('/v1/conf/status', status);

/*
app.use(express.urlencoded({
extended: true
}));*/
app.listen(port, () => console.log('listening on port 3000!'));
102 changes: 86 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"homepage": "https://github.com/yuito-it/UntitledBot-LogingSystem#readme",
"dependencies": {
"body-parser": "^1.20.2",
"deta": "^1.1.0",
"express": "^4.18.2"
}
Expand Down

0 comments on commit 6d356af

Please sign in to comment.