You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create database project
use project
create user api identified by 'tiger'
grant all privileges on project.* TO 'api'
create table people (id mediumint not null auto_increment primary key,
firstname varchar(250),
lastname varchar(250))
insert into people (firstname, lastname)
values
('john', 'smith'),
('azimuth', 'chondrite'),
('robin', 'banks'),
('justin', 'time')
Set up the nodejs project
Install required modules
$ npm init --yes
Wrote to /home/me/host/git/api/package.json:
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
$ npm install express cors mariadb
added 69 packages, and audited 102 packages in 10s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
me@me:~/host/git/api$ npm install --save-dev nodemon
up to date, audited 102 packages in 610ms
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
$ npm run dev
> api@1.0.0 dev
> nodemon api
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node api.js`
Listening on port 8080
After the API is called via the frontend, notice incoming requests printed to the console