A simple link shortener for small management
- Node.js (version 14.17.3)
- MongoDB (version 4.2) and installation instructions
Once you have the project cloned, open your terminal of choice (Command Prompt, bash, etc), navigate to the directory you cloned the project in, and run:
npm install
- Install MongoDB
- Start
mongo
from command line (you may need to go toC:\Program Files\MongoDB\Server\4.0\bin
path on windows to run the command) - Type
use your_database_name
to create database - Type
db.new_collection.insert({ some_key: "some_value" })
to initialize database - Type
to create database user.
db.createUser( { user: "your_username", pwd: "your_password", roles: [ { role: "readWrite", db: "your_database_name" } ] } )
- Type
quit()
to exit mongo
Add config.json
file in root directory with following content. You can use config-template.json
as a starting point for your own config. (do not include comments in your config.json
file)
{
"port": 3000, //server working port
"db": "mongodb://<username>:<password>@localhost:27017/<database_name>", // use values you used when setting up database
"shortlinkdomain": "http://you.site.short.com/" //final domain that the server will run
}
to run the server just run the following command in the main project folder:
node server.js
package.json
- settings for title and description of the websitepublic/css
- stylespublic/images
- images