Just a test and a note to self.
wget http://www2.census.gov/geo/tiger/GENZ2015/kml/cb_2015_us_county_500k.zip
unzip cb_2015_us_county_500k.zip
import { Static, Type } from '@sinclair/typebox' | |
import fastify, { FastifyInstance, FastifyPluginAsync } from 'fastify' | |
import type { RouteGenericInterface, RouteHandler } from 'fastify/types/route' | |
const port = 8080 | |
const requestBodySchema = Type.Object({ | |
email: Type.Readonly(Type.String({ format: 'email' })), | |
}) |
export const Main: React.FunctionComponent = () => { | |
const [ markers, setMarkers ] = React.useState<ReadonlyArray<Marker>>([]); | |
// Need to be in separate files for lazy loading, otherwise using window.google.maps | |
// in the actual map component will throw | |
return ( | |
<LoadScript googleMapsApiKey={apiKey}> | |
<Map markers={markers} /> | |
</LoadScript> | |
); |
/** | |
* Convert postal number geometries to WGS84 coordinates for geocoding | |
*/ | |
import axios from 'axios'; | |
import * as proj4 from 'proj4'; | |
import * as turf from '@turf/turf'; | |
import { promisify } from 'util'; | |
import * as fs from 'fs'; | |
const writeFile = promisify(fs.writeFile); |
import routeHandler from '../src/routeHandler'; | |
import { mockResponse, mockRequest } from './test-helpers'; | |
jest.mock('@googlemaps/google-maps-services-js'); | |
import { Client } from '@googlemaps/google-maps-services-js'; | |
const mockClient = { | |
geocode: jest.fn(), | |
}; |
import axios from 'axios'; | |
import * as proj4 from 'proj4'; | |
interface Result { | |
readonly features: ReadonlyArray<{ | |
readonly properties: { | |
readonly posti_alue: string; | |
}; | |
}>; | |
} |
const crypto = require('crypto'); | |
const ACCOUNT = '375917'; | |
const SECRET = 'SAIPPUAKAUPPIAS'; | |
const headers = { | |
'checkout-account': ACCOUNT, | |
'checkout-algorithm': 'sha256', | |
'checkout-method': 'POST' | |
}; |
var chai = require('chai'), | |
should = chai.should(), | |
expect = chai.expect(), | |
assert = chai.assert, | |
supertest = require('supertest-as-promised'), | |
api = supertest('http://localhost:3000'); | |
describe('Pictures', function () { | |
it('should add a picture', function (done) { | |
api.post('/api/v1/pictures') |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src='http://localhost:3000/socket.io/socket.io.js'></script> | |
<script> | |
var socket = io.connect('http://localhost:3000/nsa'); | |
socket.emit('request', { | |
msg : 'appA user is requesting something' | |
}); | |
socket.on('incoming-request', function(data) { |
var express = require('express'), | |
bodyParser = require('body-parser'), | |
passport = require('passport'), | |
LocalStrategy = require('passport-local').Strategy; | |
var app = express(); | |
passport.use(new LocalStrategy(function (username, password, cb) { | |
cb(null, false, {message: 'This can never succeed'}); | |
})); |