26 lines
591 B
JavaScript
26 lines
591 B
JavaScript
const express = require('express');
|
|
|
|
const read = require('./src/read');
|
|
const write = require('./src/write');
|
|
const importFromSS = require('./src/import-from-ss');
|
|
|
|
require('dotenv').config();
|
|
|
|
const app = express();
|
|
const port = process.env.PORT || 3000;
|
|
|
|
app.use(express.json());
|
|
|
|
app.post('/write', write);
|
|
app.get('/read/:hash', read);
|
|
app.post('/importFromSemanticScholar', importFromSS);
|
|
|
|
app.get('*', (req, res) => {
|
|
console.log(`404 req.path: ${req.path}`);
|
|
res.status(404).json({ errorCode: 404 });
|
|
});
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Listening on port ${port}`);
|
|
});
|