Skip to content

Instantly share code, notes, and snippets.

View franrios's full-sized avatar
🚀

Fran franrios

🚀
View GitHub Profile
FROM ubuntu:14.04
MAINTAINER Fran Rios fcojriosbello@gmail.com
# to avoid some problems:
# debconf: unable to initialize frontend: Dialog
ENV DEBIAN_FRONTEND noninteractive
# Install Nodejs...
RUN apt-get update && apt-get install -y nodejs npm
language: node_js
sudo: false
node_js:
- "4.2.1"
after_success:
- |
curl -H "Content-Type: application/json" --data '{"build": true}' -X POST https://registry.hub.docker.com/u/fcojriosbello/testingndeploying/trigger/4fcbd380-e094-4c28-9bab-95f7fe62001a/
const gulp = require('gulp')
const mocha = require('gulp-mocha')
const bg = require('gulp-bg')
var bgstart
gulp.task('start', bgstart = bg('node', './index.js'))
gulp.task('test', ['start'], function () {
return gulp.src('./test/test.js', {read: false})
.pipe(mocha({reporter: 'nyan'}))
var request = require('request')
var expect = require('chai').expect
describe('Server response', function () {
it('should return 200', function (done) {
request.get('http://localhost:8080/', function (err, res, body) {
if (err) throw err
expect(res.statusCode).to.equal(200)
done()
})
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.status(200).send('root path of the project! (Testing redeploy)\n')
})
app.listen(8080, function () {
console.log('App listening at localhost:8080')
})
@franrios
franrios / http-streams.js
Last active March 27, 2016 13:28
http-streams.js
var http = require('http')
http.createServer(function (req, res) {
var body = ''
req.setEncoding('utf8')
req.on('data', function (chunk) {
body += chunk
})
@franrios
franrios / server.js
Created March 25, 2016 19:25
server.js
var http = require('http')
var server = http.createServer().listen(8080, function () {
console.log('Listening on port 8080...')
})
server.on('request', function (req, res) {
res.write('Hello from Node.js fundamentals!\n')
res.end()
})
@franrios
franrios / hello-world.js
Last active March 25, 2016 19:14
hello-world.js
var http = require('http')
http.createServer(function (req, res) {
res.write('Hello from Node.js fundamentals!\n')
res.end()
}).listen(8080, function () {
console.log('Listening on port 8080...')
})
var fs = require ('fs')
fs.readFile('README.md', function (err, asyncData) {
if (err) throw err
console.log(asyncData.toString())
})
console.log('It is not blocked')
@franrios
franrios / blocking.js
Last active March 25, 2016 18:50
blocking node
var fs = require('fs')
var syncData = fs.readFileSync('README.md').toString()
console.log(syncData)
console.log('It is blocked')