addition
Der Text wird etwas länger
This is a simple example of how you can build a REST API based on nodejs with a mysql db as data store.
- get the code : git clone
- install dependecies : npm install
- create a local mysql database and create the table user in it, see mysql table
- define the mysql credentials in server.js
- start the rest api server : npm start
POST http://localhost:8081/api/users
{
"email": "[email protected]",
"name": "neuer name",
"password": "meinpassword",
}
GET http://localhost:8081/api/users/[email protected]
PUT http://localhost:8081/api/users/[email protected]
{
"name": "neuer name",
"password": "meinpassword"
}
DELETE http://localhost:8081/api/users/[email protected]
POST http://localhost:8081/api/auth
POST http://localhost:8081/api/auth
{
"email": "[email protected]",
"password": "meinpassword",
}
CREATE TABLE IF NOT EXISTS `user` ( `id` int(70) NOT NULL AUTO_INCREMENT, `email` varchar(45) NOT NULL, `name` varchar(45) NOT NULL, `groups` varchar(1024) NULL, `password` varchar(45) DEFAULT NULL, `join_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `email_UNIQUE` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;