You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
704 B
27 lines
704 B
const express = require('express')
|
|
const mysql = require('mysql-await');
|
|
const app = express()
|
|
const cors = require('cors');
|
|
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
|
|
const mysqlConnection = mysql.createConnection({
|
|
host: process.env.DB_HOST,
|
|
user: process.env.DB_USER,
|
|
password: process.env.DB_PWD,
|
|
database: process.env.DB_NAME
|
|
});
|
|
mysqlConnection.connect()
|
|
|
|
app.get('/songs', async (req, res)=>{
|
|
const results = await mysqlConnection.awaitQuery("SELECT * FROM songs WHERE learned=True ORDER BY title ASC");
|
|
res.json(results)
|
|
})
|
|
app.get('/instruments', async (req, res)=>{
|
|
const results = await mysqlConnection.awaitQuery("SELECT * FROM instruments");
|
|
res.json(results)
|
|
})
|
|
|
|
app.listen(18080)
|