first commit

This commit is contained in:
ubuntu-cli
2024-02-24 18:46:46 +00:00
commit 68e0f645cf
5 changed files with 1515 additions and 0 deletions

1
.gitignore vendored Executable file
View File

@ -0,0 +1 @@
node_modules/

39
index.js Executable file
View File

@ -0,0 +1,39 @@
const express = require('express');
const http = require('http');
const cors = require('cors');
const dotenv = require('dotenv');
const fileUpload = require('express-fileupload');
const app = express();
const server = http.createServer(app);
dotenv.config();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(fileUpload());
app.options('*', cors());
app.use(cors());
app.get('/', (req, res) => {
console.log("Hello World!");
res.send('Hello World!');
})
app.use('/scan', require('./routes/scan_routes'));
// app error handler
app.use((err, req, res, next) => {
console.log(err);
res.status(500).send('Something broke!');
});
module.exports = { app, server };
const port = process.env.PORT || 3000;
server.listen(port, () => {
console.log(`Server running on port ${port}`);
})

1442
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

23
package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "rfid",
"version": "1.0.0",
"description": "rfid",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js",
"dev": "nodemon index.js"
},
"author": "kicap karan",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"express-fileupload": "^1.4.3",
"express-form-data": "^2.0.23",
"mysql": "^2.18.1",
"nodemon": "^3.1.0"
}
}

10
routes/scan_routes.js Executable file
View File

@ -0,0 +1,10 @@
const express = require('express');
const router = express.Router();
router.post('/', (req, res) => {
let { uid } = req.body
console.log(uid);
return res.json({ success: true , uid: uid})
})
module.exports = router;