A project for easy-ish API creation and configuration.
Parent_Folder/ (Name NOT important)
├── dffrnt.api/ (Project-Root; any no-spaced Name will do)
│ ├── config/ (Reference only; no need to create these!)
│ └── ...
└── REDIS/ (Name important! Don't change this name!!)
In this document,
./
, refers to the project root; while,../
, refers to the parent folder
Ensure the folder structure is setup.
Ensure the prequisites are installed.
install method
you chose for REDIS
installs the files in a default location, be sure to symlink
that location to the ../REDIS/
directory.In the MySQL
database, create a user@%
for yourself.
Configure the redis.conf
file in the ../REDIS/
folder:
# ../REDIS/redis.conf
################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any other
# ...
# use a very strong password otherwise it will be very easy to break.
#
requirepass p@ssw0rd_h3r3!
In your command line, cd
into the project root location.
Install some packages at the global
level:
Run chmod +x ./.docs/npm_global.sh
to make it excutable.
Run sudo ./.docs/npm_global.sh
to install some important, *global packages.
These can be utilized across ANY or your projects:
Package | Description |
---|---|
babel-cli | A next-gen (ES6 ) JavaScript compiler. |
bower | A package-manager for Browser plugins . |
cors | A middleware for Cross-Origin Resource Sharing . |
depcheck | A tool for analyzing the dependencies in a project |
express | A fast, unopinionated, minimalist web framework for NodeJS . |
gulp | A toolkit that helps automate development workflow tasks . |
less | The dynamic stylesheet language. |
less-plugin-clean-css | A gulp plugin for LESS -> CSS using clean-css . |
nodemon | Will watch for files changes and restart your application. |
Run npm link gulp && gulp setup
to:
npm packages
.bower components
.config files
.framework modules
.In the ./config/
folder, configure the settings.js
file:
// ./config/settings.js
export default {
Debug: true, // Debug‑Mode will display verbose Logs
Port: 3001, // This is the Server's listening Port
Public: {
// Cache‑Age for Browser files
Age: 365*86400,
// ...
},
Session: {
// This should be something hard to guess, like a phrase
Secret: '¿mYd0GiS!nmYeyE&shEs4yS@uE?',
Age: (((3600*1000)*4)*1), // TTL for User Sessions
REDIS: {
Host: 'localhost', // Or whereever you keep it
Port: 6379, // Listening Port
// The password you configured earlier
Password: 'p@ssw0rd!',
},
Auth: { /* ... */ }
}
};
Still in the ./config/
folder, configure the database.js
file:
// ./config/database.js
export default {
Config: {
user: 'user', // The one you created in MySQL
database: 'mydatabase', // The DB
// ...
},
Pool: {
HeadEx1: {
host: 'XXX.XXX.XXX.XXX', // The eVectr IP
// The one you created in MySQL
password: 'p@ssw0rd_h3r3!'
},
}
};
Lastly, still in the project root, type gulp
and hit ENTER to run, and watch the logs
as the server
starts up:
Initial
gulp
tasks being completed.
File monitoring, courtesy of
nodemon
.
The
node
server starting up.
errors
, you're done!In your browser
, navigate to localhost:3001/api-explorer (or whatever port
you chose) and you'll see the API Exploration UI. Use this to test your endpoints
and/or signle sign-on
functionality.
Hit CTRL+C to stop
the server.
Initial default Configs used within the DFFRNT.API Framework.
A collection of SQL Utilities & MySQL connector.
An Express/Passport/MySQL-based API Router.
A collection of useful API Utilities & PolyFills.