Skip to content

Instantly share code, notes, and snippets.

@adamhenson
adamhenson / foo.js
Last active January 25, 2019 16:48
foo
export default (words) => console.log(words);
@adamhenson
adamhenson / zot.js
Created January 24, 2019 22:10
zot
export default {
zot: true,
};
@adamhenson
adamhenson / index.js
Created January 24, 2019 22:13
index
export { default as foo } from './foo';
export { default as zot } from './zot';
@adamhenson
adamhenson / index.spec.js
Last active January 24, 2019 23:54
index.spec.js
import * as index from '.';
describe('@zot/feature-foo package', () => {
it('should match snapshot', () => {
expect(index).toMatchSnapshot();
});
});
@adamhenson
adamhenson / index.spec.js.snap
Last active January 24, 2019 23:56
index.spec.js.snap
exports[`@zot/feature-foo package should match snapshot 1`] = `
Object {
"foo": [Function],
"zot": Object {
"zot": true,
},
}
`;
@adamhenson
adamhenson / index.js
Last active February 5, 2019 14:20
A Node.js cron job to ping an endpoint and log the response status code.
import fetch from 'node-fetch';
import schedule from 'node-schedule';
const apiUrl = 'http://api:3000/healthcheck';
const ping = async () => {
try {
const response = await fetch(apiUrl);
console.log('status', response.status);
} catch (error) {
@adamhenson
adamhenson / index.js
Last active February 5, 2019 14:14
A Node.js Express server JSON endpoint example.
import express from 'express';
const app = express();
app.get('/healthcheck', (...args) => {
const [, res] = args;
res.json({ ok: true });
});
app.listen(3000);
@adamhenson
adamhenson / cron-service.yaml
Last active February 5, 2019 14:09
A Node.js cron job - Kubernetes service configuration.
apiVersion: v1
kind: Service
metadata:
name: cron
labels:
app: cron
spec:
ports:
- port: 3000
targetPort: 3000
@adamhenson
adamhenson / api-service.yaml
Created February 5, 2019 14:09
A Node.js JSON endpoint - Kubernetes service configuration.
apiVersion: v1
kind: Service
metadata:
name: api
labels:
app: api
spec:
ports:
- port: 3000
targetPort: 3000
@adamhenson
adamhenson / webpack.config.js
Last active February 14, 2019 13:45
A simple Webpack configuration optimization.splitChunks example
const config = {
...configuration,
entry: './src/client',
optimization: {
// https://webpack.js.org/plugins/split-chunks-plugin/#optimization-splitchunks
splitChunks: {
chunks: 'all',
},
},
};