Gathering detailed insights and metrics for fonttech_base_server
Gathering detailed insights and metrics for fonttech_base_server
npm install fonttech_base_server
Typescript
Module System
Node Version
NPM Version
40.6
Supply Chain
87.7
Quality
65.8
Maintenance
40
Vulnerability
95.6
License
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
752
Last Day
1
Last Week
3
Last Month
32
Last Year
444
Minified
Minified + Gzipped
Latest Version
1.0.101
Package Id
fonttech_base_server@1.0.101
Unpacked Size
830.38 kB
Size
165.13 kB
File Count
112
NPM Version
9.8.0
Node Version
14.20.0
Published on
Jul 10, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-57.1%
3
Compared to previous week
Last Month
52.4%
32
Compared to previous month
Last Year
44.2%
444
Compared to previous year
32
______ ____ _ _ _______ _ _
| ____| / __ \ | \ | | |__ __| | | | |
| |__ | | | | | \| | | | | |_ ___ ___ | |__
| __| | | | | | . ` | | | | __| / _ \ / __| | '_ \
| | | |__| | | |\ | | | | |_ | __/ | (__ | | | |
|_| \____/ |_| \_| |_| \__| \___| \___| |_| |_|
This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API)
This project is created to help other developers create a basic REST API in an easy way with Node.js. This basic example shows how powerful and simple JavaScript can be. Do you want to contribute? Pull requests are always welcome to show more features.
cf-ipcountry
that CloudFlare creates when protecting your website).Authorization
header with value Bearer yourToken
where yourToken
is the signed and encrypted token given in the response from the login process.email: admin@admin.com
password: 12345
1git clone https://gitlab.com/fontalland/fontbaseserver.git ./fontbaseserver
1cd myproject 2npm install 3npm update
.env.example
.env
.env
is already ignored, so you never commit your credentials..env
to your environment server(development or production)server
on your environment to the url of your server, for development mode use http://localhost:3000IMPORTANT: By default token expires in 3 days (4320 minutes set in .env.example). You can refresh token at endpoint GET /token. If everything it´s ok you will get a new token.
To ensure the deliverability of emails sent by this API, Mailgun
is used for mailing users when they sign up, so if you want to use that feature go sign up at their website https://www.mailgun.com
If you want to try a different method it´s ok, I used https://nodemailer.com for this API and they have different transport methods like: smtp.
Language is automatically detected from Accept-Language
header on the request. So either you send locale manually on the request or your browser will send its default, if Accept-Language
header is not sent then it will use en
locale as default.
There are 3 available commands for this: fresh
, clean
and seed
.
1npm run command
fresh
cleans and then seeds the database with dynamic data.clean
cleans the database.seed
seeds the database with dynamic data.1npm run dev
You will know server is running by checking the output of the command npm run dev
1**************************** 2* Starting Server 3* Port: 3000 4* NODE_ENV: development 5* Database: MongoDB 6* DB Connection: OK 7****************************
It´s a good practice to do tests at your code, so a sample of how to do that in mocha/chai
is also included in the /test
directory
1npm run test
Format your code with prettier by typing:
1npm run format
Format all your markdown files with remark by typing:
1npm run remark
Lint your code with ESLint by typing:
1npm run lint
Once everything is set up to test API routes either use Postman or any other api testing application. Default username/password combination for login is admin@admin.com/12345
.
https://documenter.getpostman.com/view/487539/RWaHwoLV
You can import the example collection to Postman. To import, click the import button located and select postman-example.json
located within the root directory.
Go to manage environments
to create environments for development, production, etc. On each of the environments you create you will need to:
Create a new key authToken
and within the /login
request this value is automatically updated after a successfull login through a script located in the tests
tab. Each time you make a request to the API it will send Authorization
header with the token
value in the request, you can check this on the headers of users or cities endpoints in the Postman example.
Create a second key server
with the url of your server, for development mode use http://localhost:3000
This is a REST API, so it works using the following HTTP methods:
If you need to add more models to the project just create a new file in /app/models/
and it will be loaded dynamically.
If you need to add more routes to the project just create a new file in /app/routes/
and it will be loaded dynamically.
When you create a new controller file, try to also create another file with validations. Ex. countries.js
and countries.validate.js
. An example of this is included in the repository.
1./init-server.sh
1mongod --dbpath=/usr/local/var/mongodb/db --replSet rs0
1/usr/local/bin/redis-cli -p 6379 FLUSHALL
1npm install -g redis-commander
1redis-commander --redis-port 6379 --nosave --open
1cd /tmp 2#cd config #elasticsearch.yml config port, authentication, etc. 9200 3wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-16.7.1.tar.gz 4tar -zxvf elasticsearch-16.7.1.tar.gz 5mv elasticsearch-16.7.1 /usr/local/opt/elasticsearch 6cd /usr/local/opt/elasticsearch/ 7ln -s ../opt/elasticsearch/bin/elasticsearch /usr/local/bin/elasticsearch 8ln -s ../opt/elasticsearch/bin/elasticsearch-cli /u sr/local/bin/elasticsearch-cli 9ln -s ../opt/elasticsearch/bin/elasticsearch-env /usr/local/bin/elasticsearch-env 10cd /usr/local/opt/elasticsearch/ 11elasticsearch
1elasticsearch -d -p /usr/local/var/run/elasticsearch.pid
1 PUT /_settings 2 { 3 "index.blocks.read_only_allow_delete": null 4 }
1curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
1cd /tmp 2wget https://artifacts.elastic.co/downloads/kibana/kibana-6.5.4-darwin-x86_64.tar.gz 3tar -zxvf kibana-6.5.4-darwin-x86_64.tar.gz 4mv kibana-6.5.4-darwin-x86_64 /usr/local/opt/kibana 5ln -s ../opt/kibana/bin/kibana /usr/local/bin/kibana
1kibana
Access on: http://localhost:5601
1ngrok authtoken PUT_HERE_THE_NGROK_ACCOUNT_TOKEN
1./ngrok http 3000 -subdomain=fonttech -bind-tls=true
1./ngrok http 3000 -bind-tls=true
1ssh -o ServerAliveInterval=60 -R font-tech:80:localhost:3000 serveo.net
No vulnerabilities found.
No security vulnerabilities found.