1
1
# example-postgresql [ ![ Build Status] ( https://dev.azure.com/lganzzzo/lganzzzo/_apis/build/status/oatpp.example-postgresql?branchName=master )] ( https://dev.azure.com/lganzzzo/lganzzzo/_build/latest?definitionId=17&branchName=master )
2
2
3
- Example of a production grade entity service storing information in PostgreSQL. With Swagger-UI and configuration profiles.
4
- * Libpq is used to communicate with PostgreSQL database.*
5
- * Dockerfile and docker-compose.yaml files included.*
3
+ A complete example of a "CRUD" service (UserService) built with Oat++ and using oatpp ORM with PostgreSQL.
6
4
7
- See more:
5
+
6
+ In this example:
7
+
8
+ - How to create CRUD endpoints.
9
+ - How to use [ oatpp ORM] ( https://oatpp.io/docs/components/orm/ ) - PostgreSQL example.
10
+ - How to document API with Swagger-UI and OpenApi 3.0.0.
11
+
12
+ More about Oat++:
8
13
9
14
- [ Oat++ Website] ( https://oatpp.io/ )
10
15
- [ Oat++ Github Repository] ( https://github.com/oatpp/oatpp )
11
16
- [ Get Started] ( https://oatpp.io/docs/start )
12
17
13
18
## Overview
14
19
15
- This project is using [ oatpp] ( https://github.com/oatpp/oatpp ) and [ oatpp-swagger] ( https://github.com/oatpp/oatpp-swagger ) modules.
20
+ This project is using the following oatpp modules:
21
+
22
+ - [ oatpp] ( https://github.com/oatpp/oatpp )
23
+ - [ oatpp-swagger] ( https://github.com/oatpp/oatpp-swagger )
24
+ - [ oatpp-postgresql] ( https://github.com/oatpp/oatpp-postgresql )
16
25
17
26
### Project layout
18
27
@@ -21,11 +30,13 @@ This project is using [oatpp](https://github.com/oatpp/oatpp) and [oatpp-swagger
21
30
|- src/
22
31
| |
23
32
| |- controller/ // Folder containing Controller where all endpoints are declared
24
- | |- db/ // Database class is here
33
+ | |- db/ // Folder containing the database client
25
34
| |- dto/ // DTOs are declared here
35
+ | |- service/ // Service business logic classes (UserService)
26
36
| |- ServiceComponent.hpp // Service configuration (port, ObjectMapper, Database)
27
37
| |- SwaggerComponent.hpp // Configuration for swagger-ui
28
38
| |- AppComponent.hpp // Service configuration is loaded here
39
+ | |- DatabaseComponent.hpp // Database config
29
40
| |- App.cpp // main() is here
30
41
|
31
42
|- test/ // test folder
@@ -43,12 +54,12 @@ This project is using [oatpp](https://github.com/oatpp/oatpp) and [oatpp-swagger
43
54
44
55
** Requires**
45
56
46
- - libpq installed. To install libpq:
47
- - On Mac ` $ brew install libpq `
57
+ - This example also requires the PostgreSQL package installed.
48
58
- On Alpine ` $ apk add postgresql-dev `
49
- - On Ubuntu - goto [ Install PostgreSQL Client From Sources ] ( # install- postgresql-client-from-sources )
59
+ - On Ubuntu ` $ apt-get install postgresql-server-dev-all `
50
60
51
- - ` oatpp ` and ` oatpp-swagger ` modules installed. You may run ` utility/install-oatpp-modules.sh `
61
+ For more info see [ oatpp-postgresql/README.md] ( https://github.com/oatpp/oatpp-postgresql/blob/master/README.md )
62
+ - ` oatpp ` , ` oatpp-swagger ` and ` oatpp-postgresql ` modules installed. You may run ` utility/install-oatpp-modules.sh `
52
63
script to install required oatpp modules.
53
64
54
65
```
@@ -81,29 +92,3 @@ $ docker-compose up
81
92
82
93
Go to [ http://localhost:8000/swagger/ui ] ( http://localhost:8000/swagger/ui ) to try endpoints.
83
94
84
- ## Install PostgreSQL Client From Sources
85
-
86
- - Download sources from [ https://www.postgresql.org/ftp/source/ ] ( https://www.postgresql.org/ftp/source/ )
87
- ```
88
- $ wget https://ftp.postgresql.org/pub/source/v11.1/postgresql-11.1.tar.gz
89
- ```
90
-
91
- - Untar
92
- ```
93
- $ tar -xvzf postgresql-11.1.tar.gz
94
- ```
95
-
96
- - CD to postgresql-11.1, configure, make:
97
- ```
98
- $ cd postgresql-11.1
99
- $ ./configure
100
- $ make
101
- ```
102
- - Install PostgreSQL client-only
103
- * For this particular example we don't need full PostgreSQL installation.*
104
- ```
105
- $ make -C src/include install
106
- $ make -C src/interfaces install
107
- ```
108
-
109
- For more information see [ PostgreSQL installation guide] ( https://www.postgresql.org/docs/11/install-procedure.html#INSTALL )
0 commit comments