zero_agency_test

所属分类:推荐系统
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-10-09 21:58:53
上 传 者sh-1993
说明:  具有两个端点的JSON REST服务器:POST编辑:Id-按Id GET列表修改新闻项-PostgreSQL上的新闻项列表。光纤作为...,
(JSON REST server with two endpoints: POST /edit/:Id - Modify a news item by Id GET /list - List of news items on PostgreSQL. Fiber as the server framework. Reform is used for working with the database.)

文件列表:
.env (137, 2023-10-09)
.idea/ (0, 2023-10-09)
.idea/modules.xml (284, 2023-10-09)
.idea/sqldialects.xml (318, 2023-10-09)
.idea/vcs.xml (180, 2023-10-09)
.idea/zero_agency_test.iml (322, 2023-10-09)
Dockerfile.server (578, 2023-10-09)
cmd/ (0, 2023-10-09)
cmd/server/ (0, 2023-10-09)
cmd/server/main.go (2432, 2023-10-09)
db/ (0, 2023-10-09)
db/init.sql (31, 2023-10-09)
db/migrations/ (0, 2023-10-09)
db/migrations/000001_notes.down.sql (80, 2023-10-09)
db/migrations/000001_notes.up.sql (359, 2023-10-09)
db/models/ (0, 2023-10-09)
db/models/news.go (358, 2023-10-09)
db/models/news_categories.go (271, 2023-10-09)
db/models/news_categories_reform.go (3780, 2023-10-09)
db/models/news_easyjson.go (3128, 2023-10-09)
db/models/news_reform.go (3377, 2023-10-09)
db/models/schema_migrations.go (235, 2023-10-09)
db/models/schema_migrations_reform.go (3724, 2023-10-09)
docker-compose.yml (695, 2023-10-09)
go.mod (2045, 2023-10-09)
go.sum (30125, 2023-10-09)
internal/ (0, 2023-10-09)
internal/auth/ (0, 2023-10-09)
internal/auth/controller.go (1098, 2023-10-09)
internal/auth/handlers/ (0, 2023-10-09)
internal/auth/handlers/login.go (1857, 2023-10-09)
internal/auth/handlers/register.go (1693, 2023-10-09)
internal/auth/jwtgenerator/ (0, 2023-10-09)
internal/auth/jwtgenerator/jwtgenerator.go (1763, 2023-10-09)
internal/auth/middleware/ (0, 2023-10-09)
... ...

# Test task for Zero Agency # Description: Create a JSON REST server with two endpoints: POST /edit/:Id - Modify a news item by Id GET /list - List of news items Use MySQL for the database (PostgreSQL is also acceptable as we have migrated to it). Use Fiber as the server framework. Utilize Reform for working with the database. Establish a database connection using a connection pool. Configure all settings through environment variables and/or Viper. Input data format for the first endpoint: ``` { "Id": 64, "Title": "Lorem ipsum", "Content": "Dolor sit amet foo", "Categories": [1,2,3] } ``` If any of the fields are not provided, that field should not be updated. Output data format for the list endpoint: ``` { "Success": true, "News": [ { "Id": 64, "Title": "Lorem ipsum", "Content": "Dolor sit amet foo", "Categories": [1,2,3] }, { "Id": 1, "Title": "first", "Content": "tratata", "Categories": [1] } ] } ``` Requirements and Preferences: - If you are familiar with Docker, it would be preferable to see the service packaged in a container. - Additionally, it would be appreciated to have (bonus points compared to other candidates): - Authorization through the Authorization header and proper code structuring and grouping of endpoints. - Field validation during editing. - Pagination on the list endpoint. - Proper logging using any popular logger (e.g., logrus). - Adequate error handling. # Comments for checking: Docker: - docker-compose up --build (*server may not start from the first time due to postgreSQL needs some time to create 'zero_agency_db') Postman collection is located in root repository: - [https://github.com/ERupshis/effective_mobile/blob/main/Effective%20Mobile%20test.postman_collection.json](https://github.com/ERupshis/zero_agency_test/blob/master/zero%20agency.postman_collection.json) Authorization: - Generates JWT token and Sets it in 'Authorization' header. By default, user get simple 'user' role. Authorization (depends on role is not implemented). - *Other request should contain Authorization header for correct work. - "/login". request format: ``` { "login":"u1", "password":"p1" } ``` - "/register". request format: ``` { "login":"new_user", "password":"new_pwd" } ``` Validation: - added validation on missing fields. If server gets incorrect value type - returns error. Pagination: - /list?page=1&perPage=5, where: - page - number of page - perPage - count of notes in result. - if page is out of notes range - returns 'no content' Logging: - implemented on zap logger (https://github.com/uber-go/zap)

近期下载者

相关文件


收藏者