Skip to content

Instantly share code, notes, and snippets.

View NickNaso's full-sized avatar
🎯
Focusing

Nicola Del Gobbo NickNaso

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am NickNaso on github.
  • I am nicknaso (https://keybase.io/nicknaso) on keybase.
  • I have a public key whose fingerprint is E4C8 FE7F 27F4 F780 4334 7978 39E9 BBA6 417F A66E

To claim this, I am signing this object:

@NickNaso
NickNaso / enable_mongo.sh
Created March 21, 2016 21:35 — forked from sgnn7/enable_mongo.sh
Mongodb 3.2 on Ubuntu 15.10
echo '[Unit]
Description=High-performance, schema-free document-oriented database
After=syslog.target network.target
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
[Install]
@NickNaso
NickNaso / server.js
Created November 12, 2016 18:18
Dinamically attach routes to express app
'use strict'
const express = require('express')
const http = require('http')
const app = express()
function handleGet (req, res) {
res.send('/GET handler')
}
@NickNaso
NickNaso / API.md
Last active December 14, 2017 23:58 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@NickNaso
NickNaso / nginx.conf
Created December 23, 2016 09:13 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@NickNaso
NickNaso / proxy.js
Last active January 25, 2023 18:40
Log or modify the request body in the node-http-proxy before to pass it to the express.js application
/*******************************************************************************
* Copyright (c) 2017 Nicola Del Gobbo
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the license at http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
* IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
* MERCHANTABLITY OR NON-INFRINGEMENT.
@NickNaso
NickNaso / redirect.js
Created January 18, 2017 20:55
ExpressJS relative redirect For more info take alook here: http://expressjs.com/en/4x/api.html#res.redirect
'use strict'
const express = require('express')
const http = require('http')
const app = express()
////////////////////////////////// ROUTER /////////////////////////////////////
const router = express.Router()
@NickNaso
NickNaso / app.js
Created July 5, 2017 22:12 — forked from adrai/app.js
aws-serverless-fastify
const fastify = require('fastify')();
fastify.get('/', (request, reply) => reply.send({ hello: 'world' }));
if (require.main === module) {
// called directly i.e. "node app"
fastify.listen(3000, (err) => {
if (err) console.error(err);
console.log(`server listening on ${fastify.server.address().port}`);
});
@NickNaso
NickNaso / after_res_hooks.js
Created July 20, 2017 01:17 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@NickNaso
NickNaso / mongoose-middleware.js
Created August 8, 2017 20:13
Mongoose example of pre and post middlewares
'use strict'
const mongoose = require('mongoose')
mongoose.Promise = global.Promise
function wait(time) {
return new Promise((resolve) => {
setTimeout(resolve, time)
})