# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'
# use jwt authentication
gem 'knock', git: 'https://github.com/nsarno/knock', branch: 'master', ref: '9214cd027422df8dc31eb67c60032fbbf8fc100b'
# use file upload
gem 'carrierwave'
The reasons for using knockgem as the corresponding version are as follows.
- There was an error when using the authenticate_user method on the controller, and it was to fix it.
-
version: v1
-
UserInfo
- data
- id
- type(users)
- attributes
- token(jwt)
- name(firstName+lastName)
- country
- createAt
- updatedAt
- data
{
"data": {
"id": 1,
"type": "users",
"attributes": {
"token": "asdf.qwer.zxcv (JWT)",
"email": "[email protected]",
"name": "John Doe",
"country": "USA",
"createdAt": "2020-06-11T11:34+01:00",
"updatedAt": "2020-06-11T11:34+01:00"
}
}
}
-
ProjectData
- data
- id
- type(project)
- attributes
- title
- thumbnail(uri)
- description
- location
- type
- ownerName
- createdAt
- updatedAt
- data
-
ContentData
- data
- id
- type(content)
- attributes
- projectId
- projectOnwerName
- title
- body
- createdAt
- updatedAt
- data
-
signup(/users/signup)
- Request(POST)
- Json: firstName, lastName, email, password, country
- Response: UserInfo
- Request(POST)
-
signin(/users/signin)
- Request(POST)
- Json: auth -> email, password
"auth": {"email": "", "password": ""}
- Request(POST)
-
createProject(/projects)
- Request(POST)
- auth: jwt
- form: title, description, type, location, thumbnail
- Request(POST)
-
getProject(/projects/:id)
- Request(GET)
- Response: ProjectData
-
getAllProjects(/projects)
- Request(GET)
- Response: ProjectDataList
-
getAllOwnedProjects(/projects/my_projects)
- Request(GET)
- auth: jwt
- Response: ProjectDataList
- Request(GET)
-
updateProject(/projects/:id)
- Request(PUT)
- auth: jwt
- Json: title, description, type, location, thumbnail
- Response: ProjectData
- Request(PUT)
-
deleteProject(/projects/:id)
- Request(DELETE)
- auth: jwt
- Response: Success/ Fail
- Request(DELETE)
-
createContent(/projects/:project_id/contents)
- Request(POST)
- auth: jwt
- Json: title, body
- Response: ContentData
- Request(POST)
-
getContents(/projects/:project_id/contents)
- Request(GET)
- Response: ContentDataList
-
getSpecificContent(/projects/:project_id/contents/:id)
- Request(GET)
- Response: ContentData
-
updateContent(/contents/:id)
- Request(PUT)
- auth: jwt
- Json: title, body
- Response: ContentData
- Request(PUT)
-
deleteContent(/contents/:id)
- Request(DELETE)
- auth: jwt
- Response: Success/ Fail
- Request(DELETE)
It is written based on Centos8.3.
-
Install ruby-2.7.2
-
Export Environment variable
export SECRET_KEY_BASE=GENERATED_CODE
- db migrate
rake db:migrate RAILS_ENV=production
- run rails server on production level
rails s -e production