A shell script that initializes a new project and sets up a Node.js environment with either MongoDB or PostgreSQL as the database.
- Clone the repository or download the script file.
- In the terminal, navigate to the directory where the script file is located.
- Make the script file executable by running `chmod +x project-init.sh.
- Run the script file by executing `./project-init.sh.
- The script will prompt you to enter the name of the project and choose a database (either MongoDB or PostgreSQL).
- The script will create a new directory for the project and set up the Node.js environment with the chosen database.
- The script will install necessary dependencies and set up a
server.js
file that starts an Express server on port 3000 (or the port specified in theprocess.env.PORT
environment variable).
- Node.js and npm must be installed on the system.
- jq must be installed for the script to correctly set the "dev" script and type in the
package.json
file. jq can be installed withbrew install jq
in the terminal.
- The MongoDB setup requires a valid connection URI. The script provides a sample URI that needs to be replaced with your own.
- The PostgreSQL setup requires the following environment variables to be set:
DB_HOST
,DB_PORT
,DB_USER
,DB_PASSWORD
, andDB_NAME
.
|
|–– src
|–––|
|–––|–– server
|–––|–––|
|–––|–––|–– database
|–––|–––|–––|
|–––|–––|–––|–– connection.js
|–––|–––|
|–––|–––|–– models
|–––|–––|–– routes
|–––|–––|–– middleware
|–––|
|–––|–– pages
|–––|–– views
|–––|–– assets
|–––|–– services
|
|–– server.js
|–– package.json