-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
39 lines (31 loc) · 829 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require './app/config/environment'
require 'logger'
logger = Logger.new($stdout) # create a new logger that writes to the console
logger.info('Starting application...')
# Routes for Authentication
post '/auth/login' do
params = JSON.parse(request.body.read)
result = AuthController.login(params)
result.to_json
end
# Routes for Users CRUD
post '/users' do
params = JSON.parse(request.body.read)
result = UsersController.create(params)
result.to_json
end
get '/users' do
UsersController.read_all.to_json
end
get '/users/:id' do
UsersController.read_one(params[:id]).to_json
end
put '/users/:id' do
params = JSON.parse(request.body.read)
result = UsersController.update(params[:id], params)
result.to_json
end
delete '/users/:id' do
result = UsersController.delete(params[:id])
result.to_json
end