Skip to content

Instantly share code, notes, and snippets.

Avatar
🐣

Joyce Lin loopDelicious

🐣
View GitHub Profile
@loopDelicious
loopDelicious / index.js
Created May 15, 2020
Create a `/spacetasks` route using the `GET` method to retrieve a list of chores for the space station
View index.js
app.get("/spacetasks", (req, res, next) => {
res.json([
"wash the spaceship",
"clean the space kitchen",
"look at the stars",
"repair my space suit"
])
})
View ddclient-secret.yaml
---
# UPDATE THIS SECRET BEFORE APPLYING
apiVersion: v1
kind: Secret
metadata:
name: ddclient-secret
data:
ddclient.conf: |
protocol=cloudflare, \
zone=meowsergirl.com, \
View deployment.yaml
---
# The main bit: the Deployment of our container.
apiVersion: apps/v1
kind: Deployment
metadata:
name: ddclient
spec:
replicas: 1
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
View config.js
var secret = require('./secrets.js');
module.exports = {
"collections": [
{
"from": "swagger",
"to": "postman-collection",
"name": "Swagger Petstore",
"collection_uid": "1559979-81f30228-c4e1-8a05-948a-da9cc9bd07db",
"collection_id": "81f30228-c4e1-8a05-948a-da9cc9bd07db"
View converter.js
var fs = require('fs'),
Converter = require('swagger2-postman2-converter'),
request = require('request'),
config = require('./config.js');
// ###############################################
// define functions to handle conversion and update collection
View converter.js
var fs = require('fs'),
Converter = require('swagger2-postman2-converter');
function handleConversion(originalFileName, newFileName) {
// read the local swagger file
var swaggerObject = JSON.parse(
fs.readFileSync(originalFileName, 'utf8')
);
@loopDelicious
loopDelicious / script.js
Created Aug 28, 2017
Example of writing to a local file
View script.js
var express = require('express');
var fs = require('fs');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json()); // Body parser use JSON data
app.post('/launches', function(req, res) {
@loopDelicious
loopDelicious / .travis.yml
Last active Dec 12, 2019
Integrate API tests with Postman, Newman, and Travis CI
View .travis.yml
language: node_js
node_js:
- "8.2.1"
install:
- npm install newman
before_script:
- node --version
- npm --version
View gist:e129f24f340a5d0a327c4716ab585456
// Load the JSON Schema
const customerSchema = JSON.parse(environment.customerSchema);
// Test whether the response matches the schema
var customer = JSON.parse(responseBody);
tests["Customer is valid"] = tv4.validate(customer, customerSchema);
@loopDelicious
loopDelicious / mlab.js
Last active Nov 23, 2016
CRUD example endpoints
View mlab.js
var express = require('express');
var request = require('request');
var bodyParser = require('body-parser');
var key = require('../secrets.js');
var app = express();
// allow CORS access
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
You can’t perform that action at this time.