Skip to content

Commit 27e998a

Browse files
authored
Move server code into server directory (sqlpad#398)
Move server package.json and related things into server directory
1 parent cf8dc0f commit 27e998a

29 files changed

Lines changed: 3340 additions & 1845 deletions

.dockerignore

Lines changed: 0 additions & 13 deletions
This file was deleted.

.eslintignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.idea/*
44
.vscode/settings.json
55
client/build/
6+
server/public
67
coverage/
78
db/
89
dbtest/

.npmignore

Lines changed: 0 additions & 27 deletions
This file was deleted.

.prettierignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ client/package.json
55
client/package-lock.json
66
db/*
77
dbtest/*
8-
package-lock.json
9-
package.json
8+
server/package-lock.json
9+
server/package.json

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ before_install:
1212
- npm i -g npm@5
1313
cache:
1414
directories:
15-
- "node_modules"
15+
- "client/node_modules"
16+
- "server/node_modules"
17+
install:
18+
- scripts/build.sh
19+
script:
20+
- scripts/lint.sh
21+
- npm run test --prefix server

README.md

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,52 +26,94 @@ Some configuration is exposed via environment variables. See [configItems.js](ht
2626

2727
See [docker-validation](https://github.com/rickbergfalk/sqlpad/tree/master/docker-validation) folder for example docker-compose setup with SQL Server.
2828

29+
## Building
30+
31+
- Clone/download this repo
32+
- Install node 8 or later ([nvm recommended](https://github.com/creationix/nvm))
33+
- Ensure you have the latest npm
34+
35+
```sh
36+
npm install npm -g
37+
```
38+
39+
- Install dependencies and build the UI
40+
41+
```sh
42+
scripts/build.sh
43+
```
44+
45+
At this point you can run the SQLPad server with the frontend built for production use:
46+
47+
```sh
48+
cd server
49+
node server.js --dir ../db --port 3010 --base-url '/sqlpad'
50+
```
51+
52+
If prefered, SQLPad can be installed as a global module using the local files in this repo. This allows running SQLPad via the cli in any directory, just as if you had installed it with `npm install sqlpad -g`
53+
54+
```sh
55+
cd server
56+
node install -g
57+
58+
# Now from somewhere else you can run sqlpad like
59+
cd ~
60+
sqlpad --dir ../db --port 3010 --base-url '/sqlpad'
61+
```
62+
63+
A docker image may be built using the Dockerfile located in `server` directory. See `docker-publish.sh` for example docker build command.
64+
2965
## Development
3066

31-
* Clone/download this repo
32-
* Install node 8 or later ([nvm recommended](https://github.com/creationix/nvm))
33-
* Ensure you have the latest npm
67+
- Clone/download this repo
68+
- Install node 8 or later ([nvm recommended](https://github.com/creationix/nvm))
69+
- Ensure you have the latest npm
3470

3571
```sh
3672
npm install npm -g
3773
```
3874

39-
* Install dependencies (front and back)
75+
- Install dependencies and build the UI
4076

4177
```sh
42-
npm ci --prefix client
43-
npm ci
78+
scripts/build.sh
4479
```
4580

46-
* Build front-end
81+
- Open 2 terminal sessions in the root of this repo.
82+
83+
In one install the backend dependencies and start the development server
4784

4885
```sh
49-
npm run build
86+
npm start --prefix server
5087
```
5188

52-
* Start dev server
89+
In the other install frontend dependencies and start the devleopment server
5390

5491
```sh
55-
npm start
92+
npm start --prefix client
5693
```
5794

58-
At this point you should have both back-end and front-end development servers running.
95+
At this point you should have both backend and frontend development servers running.
5996

60-
http://localhost:3000 serves react front-end in dev-mode
61-
http://localhost:3010 serves front-end compiled for production
97+
http://localhost:3000 serves React-based frontend in dev-mode
98+
http://localhost:3010 serves frontend compiled for production
6299

63-
When viewing the front end in development mode, the page will automatically refresh on front-end file change. The back-end server will always auto-restart on file change.
100+
When viewing the frontend in development mode, the page will automatically refresh on frontend file change. The backend server will auto-restart on backend file change.
64101

65-
### Databases
102+
### Optional step
66103

67104
A docker-compose file with is provided to provide an empty postgres database to test with.
68-
If you have docker installed you can do the following:
105+
If you have docker installed, in a third terminal session you can do the following:
69106

70107
```sh
71108
# Bring database containers up in background
109+
docker-compose up
110+
111+
# control-c will stop the databases in docker compose
112+
113+
# If you would like to run this in the background, run
72114
docker-compose up -d
73115

74-
# To bring database down
116+
# To bring database down from background
75117
docker-compose down
76118

77119
# To remove dangling containers volumes etc

client/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public
2+
build
File renamed without changes.

client/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock.json
2+
package.json

0 commit comments

Comments
 (0)