Skip to content

Commit

Permalink
Merge pull request #15 from ciatph/dev
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
ciatph authored Apr 7, 2022
2 parents 13e024f + 6afda6b commit e9e4167
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,24 @@ A basic web app client in the **/client** directory will show basic API usage an
## Usage

1. Navigate to the `/server` directory.
2. Generate the API documentation.
2. Create a default Firebase Auth user.
`npm run seed`
3. Generate the API documentation.
`npm run gen:docs`
3. Run the app:
4. Run the app:
- (development mode) `npm run dev`
- (production mode) `npm start`
4. Read the API documentation and usage examples guide of available CRUD API endpoints on:
5. Read the API documentation and usage examples guide of available CRUD API endpoints on:
`http://localhost:3001/docs`
5. Try to log-in to the `/client` app using the default superadmin seeded user:
6. Try to log-in to the `/client` app using the default superadmin seeded user from step no. 2:
```
username: superadmin@gmail.com
password: 123456789
```
6. Use the CRUD API endpoints to create/update/delete or view Firebase Auth users using Postman, curl, or other http clients.
7. Use the CRUD API endpoints to create/update/delete or view Firebase Auth users using Postman, curl, or other http clients.
- Try signing in these users to the `/client` app.



## Available Scripts - server

The npm scripts listed below are available under the **/server** directory.
Expand Down Expand Up @@ -108,5 +109,16 @@ password: 123456789
account_level: 1
```

### `npm run copyclient`

Copies the built `/client` website from `/client/build` to the server's root directory.

- It requires to build the client app first, after following its set-up [instructions](#client):
```
cd client
npm run build
```
- The built client app will be viewable on `http://localhost:3001` if the server is running.

@ciatph
20220406
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.0.0",
"description": "API for Firebase Authentication users management using the firebase-admin SDK.",
"main": "index.js",
"engines": {
"node": "14.x"
},
"scripts": {
"install": "cd server && npm install",
"build": "cd server && npm run build",
Expand Down
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"seed": "node src/scripts/seeder.js",
"lint": "eslint src --ignore-path .gitignore",
"lint:fix": "eslint --ignore-path .gitignore --fix src",
"copyclient": "node src/scripts/copyclient.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ app.use(cors({

app.use('/api', controllers)

app.get('/', (req, res) => {
res.status(200).send('OK!')
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'public', 'index.html'))
})

app.listen(PORT, () => {
Expand Down
15 changes: 15 additions & 0 deletions server/src/scripts/copyclient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs-extra')
const path = require('path')

// Copy the /client build (website) directory to the server's public root directory
const copyClientApp = async (src, dest) => {
fs.move(src, dest, { overwrite: true })
.then(() => console.log('success!'))
.catch(err => console.log(err.message))
}

(async () => {
const source = path.resolve(__dirname, '..', '..', '..', 'client', 'build')
const destination = path.resolve(__dirname, '..', 'public')
await copyClientApp(source, destination)
})()

0 comments on commit e9e4167

Please sign in to comment.