This commit is contained in:
xfarrow
2023-10-13 10:37:09 +02:00
parent 69559fabec
commit 190313f1b1
3 changed files with 72 additions and 31 deletions

View File

@ -1,5 +1,4 @@
/*
This code is part of Blink
licensed under GPLv3
@ -8,27 +7,23 @@
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
// require() always returns a function
const express = require('express');
const api_controller = require('./api_controller.js');
require('dotenv').config();
// We can do express() because the express
// module exports a function. Exporting a function
// means making a JavaScript function defined in one
// module available for use in another module.
const app = express();
const port = 3000;
const port = process.env.API_SERVER_PORT;
// Middleware which parses JSON for POST requests
app.use(express.json());
app.post('/blinkapi/register', api_controller.register);
app.post('/blinkapi/login', api_controller.login);
app.get('/blinkapi/person/:id', api_controller.verifyToken, api_controller.person);
// Start the server
app.listen(port, () => {