mirror of
https://github.com/selfxyz/self.git
synced 2026-02-08 13:25:59 -05:00
abiility to skip scan and retrieve cached data
This commit is contained in:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user