2024-03-19 22:22:36 -05:00
|
|
|
const express = require('express');
|
2024-04-19 18:08:18 -05:00
|
|
|
|
|
|
|
const read = require('./src/read');
|
|
|
|
const write = require('./src/write');
|
|
|
|
const importFromSS = require('./src/import-from-ss');
|
2024-03-19 22:22:36 -05:00
|
|
|
|
|
|
|
require('dotenv').config();
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const port = process.env.PORT || 3000;
|
2024-03-23 15:26:27 -05:00
|
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
2024-04-19 18:08:18 -05:00
|
|
|
app.post('/write', write);
|
|
|
|
app.get('/read/:hash', read);
|
|
|
|
app.post('/importFromSemanticScholar', importFromSS);
|
2024-03-19 22:22:36 -05:00
|
|
|
|
|
|
|
app.get('*', (req, res) => {
|
2024-04-04 12:55:59 -05:00
|
|
|
console.log(`404 req.path: ${req.path}`);
|
|
|
|
res.status(404).json({ errorCode: 404 });
|
2024-03-19 22:22:36 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Listening on port ${port}`);
|
|
|
|
});
|