Skip to content

Instantly share code, notes, and snippets.

View aherve's full-sized avatar

Aurélien aherve

View GitHub Profile
describe('postCreatePlugin', function () {
let MyModel, spy1, spy2
before(function(done) {
const MySchema = new mongoose.Schema({
foo: String,
})
MySchema.plugin(postCreatePlugin)
MyModel = mongoose.model('MyModel', MySchema)
import postCreate from '/wathever/postCreate.js'
//... Your schema definition as usual
// declare the plugin for your model
mySchema.plugin(postCreate)
// anywhere else:
mySchema.addPostCreate(function (user, cb) {
// this will only be executed ad the user creation
FROM alpine
RUN mkdir /app
WORKDIR /app
RUN apk update && \
apk add imagemagick python ghostscript-fonts ghostscript py-pip groff && \
pip install awscli
ADD work.sh .
######### READ ENV VARIABLES ###########
echo "reading env variables"
eval `./jsonenv.py < $PAYLOAD_FILE`
eval `./jsonenv.py < $CONFIG_FILE`
######### DOWNLOAD FILE ###########
echo "downloading"
aws s3 cp s3://$S3_INPUT_BUCKET/$S3_INPUT_DIRNAME/$S3_INPUT_FILENAME ./orig.pdf
worker:
encrypted_env_file: encrypted.env
build: .
volumes:
- ./test:/app/test
volumes_from:
- utils
environment:
- PAYLOAD_FILE=./test/payload.json
- CONFIG_FILE=/data/iron_config.json
- type: serial
name: "PREPARE IRON CONFIG ENV"
service: utils
steps:
- command: sh -c "echo $IRON_JSON > /data/iron_config.json"
- type: serial
name: "TESTING"
service: worker
steps:
import IronWorker from 'iron_worker'
const task = {
"WATERMARK_TEXT":"TESTING TESTING TESTING",
"S3_INPUT_BUCKET":"my-bucket",
"S3_INPUT_FILENAME":"some-file-that-you-own.pdf",
"S3_INPUT_DIRNAME":"the-input-directory",
"S3_DEST_BUCKET":"my-bucket",
"S3_DEST_FILENAME":"testing-output.pdf",
"S3_DEST_DIRNAME":"test"
import DemoController from './demo.controller'
import DemoService from './demo.service'
import routes from './demo.routes'
angular.module('hunteed.demo', [])
.controller('DemoController', DemoController)
.service('DemoService', DemoService)
.config(routes)
export default class DemoController {
constructor (DemoService) {
'ngInject'
Object.assign(this, {DemoService})
}
}
export default class DemoService {
constructor () {
'ngInject'
Object.assign(this, {
data: {},
})
}
fetchData () {
this.data = {foo: 'bar'}