A simple url shortener.
- Node.js (with npm)
To install dependencies, navigate to project root in the terminal and run:
npm i
After installation of dependencies, proceed with one of two options given below:
To quickly try the application, it may be run with a sqlite3 instance.
To do this, make the following changes in config/database.js
const sequelize = new Sequelize('database', null, null, {
dialect: 'sqlite',
storage: 'database.sqlite',
logging: false,
})
Then, to start the app locally:
npm start
With this option, a database.sqlite
is created at project root.
For practical usage, a PostgreSQL database is preferred over sqlite. For this option, no modification of config/database.js is needed. Dependencies for PostgreSQL support should have installed during the setup step.
The credentials for database connection are to be stored in a .env
file created at the root of the project in the following format:
DB_USERNAME=<postgres-db-username-here>
DB_PASSWORD=<postgres-db-password-here>
DB_HOST=<postgres-db-host-here>
DB_PORT=<postgres-db-port-here>
DB_NAME=<postgres-db-name-here>
Then, to start the app locally:
npm start
As this project uses Sequelize ORM, other databases supported by it can be used. This approach requires changing some dependencies and possible additonal configurations. For more information, visit Sequelize ORM Documentation.