Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zrg-team/go_respository
https://github.com/zrg-team/go_respository
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zrg-team/go_respository
- Owner: zrg-team
- Created: 2020-03-18T08:16:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-18T09:19:00.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T22:46:28.644Z (7 months ago)
- Language: Go
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# About (In progress)
Project for building RESTful APIs and microservices using Golang, [mux](https://github.com/gorilla/mux) and Mariadb
Inspiring by [node_express_respository](https://github.com/zrg-team/node_express_respository)
We focus on:
+ Easy to start
+ Reduce copied code
+ Readable code
+ Simple to implement new api for a model like: search, create, update
+ etc## Features
+ Mux + Mariadb
+ Uses [Gorm](https://github.com/jinzhu/gorm) as ORM
+ [Docker](https://www.docker.com/) support
+ Load environment variables from env file
+ Authentication and Authorization with [JWT](https://jwt.io/)
+ Support repositories
+ Default search feature## Requirements
+ [Golang](https://golang.org/)
+ [Docker]((https://www.docker.com/))## Structure motivation
#### 1. We separate routes into many files based on main model. ex:
user.js
- POST / => /user/
- POST /login => /user/login
- POST /verify => /user/verify
- GET / => /user/
- GET /version => /user/version...
#### 3. Repositories is used to abstract the data layer, making our application more flexible to maintain.
Methods:
- create
- update
- findById
- find
- paginate#### 4. Controllers handles requests using repository layer
#### 5. Criteria: Default criteria supported fast search on a repository, push criteria to your request using below code
http://api.local/users?search=name:John%20Doe
or
http://api.local/users?search=name:John&searchFields=name:like
or
http://api.local/users?search=email:[email protected];name=john&searchFields=email:=;name:like
By default DefaultCriteria makes its queries using the AND comparison operator for each query parameter.
http://api.local/users?search=email:[email protected];age=18&searchFields=email:=;age:>=
The above example will execute the following query:
```
SELECT * FROM users WHERE age >= 18 AND email = '[email protected]';
```In order for it to query using the OR, pass the searchJoin parameter as shown below:
http://api.local/users?search=email:[email protected];age=18&searchFields=email:=;age:>=&searchJoin=or
Filtering fields
http://api.local/users?fields=id;name
Sorting the results
http://api.local/users?order=name:desc
#### 6.Domain logic should put to services folders