abiility to skip scan and retrieve cached data

This commit is contained in:
0xturboblitz
2023-07-27 14:56:42 +02:00
parent 6f1d70eaf4
commit e430da977d
7 changed files with 83 additions and 18 deletions

View File

@@ -7,7 +7,7 @@ const app = express();
// parse application/json
app.use(bodyParser.json());
app.post('/passportData', (req: Request, res: Response) => {
app.post('/post', (req: Request, res: Response) => {
const data = req.body;
fs.writeFile('passportData.json', JSON.stringify(data, null, 2), err => {
if (err) {
@@ -19,6 +19,17 @@ app.post('/passportData', (req: Request, res: Response) => {
});
});
app.get('/passportData', (req: Request, res: Response) => {
fs.readFile('passportData.json', (err, data) => {
if (err) {
console.log(err);
res.status(500).json({message: 'An error occurred while reading file'});
} else {
res.json(JSON.parse(data.toString()));
}
});
});
const port = 3000;
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);