You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-50Lines changed: 33 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,11 @@
1
1
# Node API and Client Boilerplate
2
2
Required node version is `9.2.1`. The [API](https://github.com/rickyhurtado/node-client-and-api-boilerplate/tree/master/api) app is powered by [Express](https://expressjs.com/) and [PostgreSQL](https://www.postgresql.org/) database and the [client](https://github.com/rickyhurtado/node-client-and-api-boilerplate/tree/master/client) app is bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app) and [Bootstrap 3.3](http://getbootstrap.com/docs/3.3/) framework and theme.
3
3
4
-
## Running the Apps
4
+
## Starting the Apps
5
5
6
-
### Cloning the project:
6
+
### Express API
7
7
8
-
Open a terminal console and run the following scripts:
Note: Only change the environment variables for `POSTGRES_USER` and `POSTGRES_PASSWORD` if working on local machine.
18
9
19
10
Open a terminal console and change the project directory from `root` to `api`. Copy `.env.dist` to `.env` and change the values of the environment variables if needed.
Note: Only change the environment variables for `POSTGRES_USER` and `POSTGRES_PASSWORD` if working on local machine.
32
-
33
-
Then run the following scripts in the terminal:
22
+
Then run the following commands:
34
23
35
24
```
36
25
yarn
37
26
yarn start
38
27
```
39
28
40
-
Access the client app at <http://localhost:7770>.
29
+
Note: The database must be created and initialized after starting the app on fresh installation. See **Database using PostgreSQL and Sequelize** section. See **Bash Commands** section for Docker.
30
+
31
+
Access the app at <http://localhost:7770>.
41
32
42
-
**React App**
33
+
### React App
43
34
44
35
Open a terminal console and change the project directory from `root` to `client`. Copy `.env.dist` to `.env` and change the values of the environment variables if needed.
To generate the `./client/src/Assets/Styles/Style.css`, open another terminal window and change the project directory from `root` to `client` then run the following script:
53
+
Note: See **Bash Commands** section for Docker.
54
+
55
+
To generate the `./client/src/Assets/Styles/Style.css`, open another terminal console and change the project directory from `root` to `client` then run the following command:
62
56
63
57
```
64
58
yarn run watch-css
65
59
```
66
60
67
-
The script above works only in Mac with the `fsevents` module installed. Run the script below as an alternative:
61
+
The command above works only in Mac with the `fsevents` module installed. Run the command below as an alternative:
68
62
69
63
```
70
64
yarn run build-css
71
65
```
72
66
73
-
Note: You must run the script above manually everytime you made changes to `.scss` files. All the `*.scss` files shall be compiled to `*.css` but only the `Style.css` is included in the repository.
67
+
Note: You must run the command above manually everytime you made changes to `.scss` files. All the `*.scss` files shall be compiled to `*.css` but only the `Style.css` is included in the repository.
74
68
75
-
Access the API app at <http://localhost:7771>.
69
+
Access the client app at <http://localhost:7771>.
76
70
77
-
### Starting the React App and Express API in Docker:
71
+
##Docker
78
72
79
-
Download and install the [Docker Community Edition](https://www.docker.com/community-edition). With [Docker](https://www.docker.com/), both the API and client apps can be started using one script. First, do the same instructions above except for the `yarn`, `yarn start`, and `yarn global add detect-port` scripts. Then change directory to `root`, and run the following scripts in the terminal:
73
+
Download and install the [Docker Community Edition](https://www.docker.com/community-edition). With [Docker](https://www.docker.com/), both the API and client apps can be started using one command.
80
74
81
-
```
82
-
docker-compose build
83
-
docker-compose up
84
-
```
85
-
86
-
Note: The `docker-compose build` script is executed only once if the Docker image has not been created yet.
87
-
88
-
To shutdown the apps, press `CTRL+C` and run the following script in the terminal:
89
-
90
-
```
91
-
docker-compose down
92
-
```
75
+
Note: See **Bash Commands** section for Docker.
93
76
94
-
The `yarn run watch-css`script should be running on a separate terminal window for client app.
77
+
The `yarn run watch-css`command should be running on a separate terminal console for client app.
95
78
96
79
## Database using PostgreSQL and Sequelize
97
80
98
-
### Local
99
-
100
81
**Installing PostgreSQL**
101
82
102
83
**Mac:**[Getting Started with PostgreSQL on Mac OSX](https://www.codementor.io/engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb)
103
84
<br>
104
85
**Windows:**[Installing PostgreSQL, Creating a User, and Creating a Database](https://confluence.atlassian.com/display/CONF30/Database+Setup+for+PostgreSQL+on+Windows)
105
86
106
-
NOTE: For Mac users, you can run the PostgreSQL server on a separate terminal console by running the following script:
87
+
NOTE: For Mac users, you can run the PostgreSQL server on a separate terminal console by running the following command:
107
88
108
89
```
109
90
postgres -D /usr/local/var/postgres
110
91
```
111
92
112
-
**Database Create and Drop Commands**
93
+
**Create and Initialize Database**
113
94
114
-
Open a terminal console and change the project directory from `root` to `api` and run the following script:
95
+
Open a terminal console and change the project directory from `root` to `api` and run the following command:
115
96
116
97
```
117
98
sequelize db:create
99
+
sequelize db:migrate
100
+
sequelize db:seed:all
118
101
```
119
102
120
-
To drop database, run the following script:
103
+
To drop database, run the following command:
121
104
122
105
```
123
106
sequelize db:drop
124
107
```
125
108
126
-
### Docker
127
-
128
-
See **Bash Commands** below.
109
+
See **Bash Commands** section for Docker.
129
110
130
111
## Bash Commands
131
112
132
113
From the `root` directory of the project, run the following commands:
133
114
115
+
Note: To view the Docker containers, open another terminal then enter `docker ps`. To manage separate Docker instance for API or client, open another terminal console and change the project directory from `root` to `api` or `client` and run the commands below.
|`./bin/install`| Build the Docker container and initialise database |
138
122
|`./bin/start`| Build and run all the services (API, client, and database) |
139
123
|`./bin/stop`| Stop all the services |
140
124
|`./bin/console <container ID or Name>`| Access the terminal console of API or client container |
141
125
142
-
Note: To view the Docker containers, open another terminal then enter `docker ps`. To manage separate Docker instance for API or client, open another terminal window and change the project directory from `root` to `api` or `client` and run the commands above.
126
+
Note: To manage separate Docker instance for API or client, open another terminal console and change the project directory from `root` to `api` or `client` and run the commands above.
Copy file name to clipboardExpand all lines: api/README.md
+51-23Lines changed: 51 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
# Express API Boilerplate
2
2
Required node version is `9.2.1`. The API app is powered by [Express](https://expressjs.com/) and [PostgreSQL](https://www.postgresql.org/) database.
3
3
4
-
## Running the App
4
+
## Starting the API App
5
5
6
-
### Starting the app in local:
6
+
Note: Only change the environment variables for `POSTGRES_USER` and `POSTGRES_PASSWORD` if working on local machine.
7
7
8
8
Open a terminal console and change the project directory from `root` to `api`. Copy `.env.dist` to `.env` and change the values of the environment variables if needed.
Note: Only change the environment variables for `POSTGRES_USER` and `POSTGRES_PASSWORD` if working on local machine.
21
-
22
-
Then run the following scripts in the terminal:
20
+
Then run the following commands:
23
21
24
22
```
25
23
yarn
26
24
yarn start
27
25
```
28
26
29
-
Access the client app at <http://localhost:7770>.
27
+
Note: The database must be created and initialized after starting the app on fresh installation. See **Database using PostgreSQL and Sequelize** section. See **Bash Commands** section for Docker.
28
+
29
+
Access the app at <http://localhost:7770>.
30
+
31
+
## Docker
32
+
33
+
Download and install the [Docker Community Edition](https://www.docker.com/community-edition).
34
+
35
+
Note: See **Bash Commands** section for Docker.
36
+
37
+
## Database using PostgreSQL and Sequelize
38
+
39
+
**Installing PostgreSQL**
30
40
31
-
### Starting the App in Docker:
41
+
**Mac:**[Getting Started with PostgreSQL on Mac OSX](https://www.codementor.io/engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb)
42
+
<br>
43
+
**Windows:**[Installing PostgreSQL, Creating a User, and Creating a Database](https://confluence.atlassian.com/display/CONF30/Database+Setup+for+PostgreSQL+on+Windows)
32
44
33
-
Download and install the [Docker Community Edition](https://www.docker.com/community-edition). With [Docker](https://www.docker.com/), both the API and client apps can be started using one script. First, do the same instructions above except for the `yarn`, `yarn start`, and `yarn global add detect-port` scripts. Then change directory to `root`, and run the following scripts in the terminal:
45
+
NOTE: For Mac users, you can run the PostgreSQL server on a separate terminal console by running the following command:
34
46
35
47
```
36
-
docker-compose build
37
-
docker-compose up
48
+
postgres -D /usr/local/var/postgres
38
49
```
39
50
40
-
Note: The `docker-compose build` script is executed only once if the Docker image has not been created yet.
51
+
**Create and Initialize Database**
41
52
42
-
To shutdown the app, press `CTRL+C`and run the following script in the terminal:
53
+
Open a terminal console and change the project directory from `root` to `api`and run the following command:
43
54
44
55
```
45
-
docker-compose down
56
+
sequelize db:create
57
+
sequelize db:migrate
58
+
sequelize db:seed:all
46
59
```
47
60
61
+
To drop database, run the following command:
62
+
63
+
```
64
+
sequelize db:drop
65
+
```
66
+
67
+
See **Bash Commands** section for Docker.
68
+
48
69
## Bash Commands
49
70
50
-
Change the project directory from `root` to `api` then run the following commands:
71
+
From the `root` directory of the project, run the following commands:
72
+
73
+
Note: To view the Docker containers, open another terminal then enter `docker ps`. To manage separate Docker instance for API, open another terminal console and change the project directory from `root` to `api` and run the commands below.
|`./bin/install`| Build the Docker containers and initialise database |
80
+
|`./bin/start`| Build and run all the services (API and database) |
81
+
|`./bin/stop`| Stop all the services |
82
+
|`./bin/console <container ID or Name>`| Access the terminal console of API container |
59
83
60
-
Note: To view the Docker containers, open another terminal then enter `docker ps`. To manage separate Docker instance for API, open another terminal window and change the project directory from `root` to `api` and run the commands above.
84
+
Note:
85
+
86
+
- To view the Docker containers, open another terminal then enter `docker ps`
87
+
- To manage separate Docker instance for API, open another terminal console and change the project directory from `root` to `api` and run the commands above
0 commit comments