This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prisma.yml | |
# Name of our project | |
service: graphql-server-file-upload-example | |
# Creates a development cluster on your local Docker instance | |
stage: dev | |
cluster: local | |
# Paths to our datamodel files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# database/datamodel/types.graphql | |
type File { | |
id: ID! @unique | |
name: String! | |
size: Int! | |
secret: String! @unique | |
contentType: String! | |
createdAt: DateTime! | |
updatedAt: DateTime! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/modules/fileApi.ts | |
import * as multiparty from 'multiparty' | |
let form = new multiparty.Form() | |
form.on('part', async function(part) { | |
if (part.name !== 'data') { | |
return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/index.ts | |
import { S3 } from 'aws-sdk' | |
// Creates S3 client | |
const s3client = new S3({ | |
accessKeyId: process.env.S3_KEY, | |
secretAccessKey: process.env.S3_SECRET, | |
params: { | |
Bucket: process.env.S3_BUCKET | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'isomorphic-fetch' | |
export const uploadFile = file => { | |
const data = new FormData() | |
data.append('data', file) | |
return fetch(GRAPHCOOL_FILE_URL, { | |
method: 'POST', | |
body: data, | |
credentials: 'same-origin' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"dependencies": { | |
"apollo-client-preset": "^1.0.3", | |
"expo": "^22.0.2", | |
"graphql": "^0.11.7", | |
"graphql-tag": "^2.5.0", | |
"react": "16.0.0-beta.5", | |
"react-apollo": "^2.0.1", | |
"react-native": "^0.49.5", | |
"react-native-camera": "^0.12.0", | |
"styled-components": "^2.2.3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
unset FOO | |
echo "env: $NODE_ENV" | |
if [ "$NODE_ENV" == "production" ] | |
then | |
export FOO=qux | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 | |
-- src/ | |
-- users/ | |
-- model.js | |
-- actions.js | |
-- views.js | |
-- exams/ | |
-- votes/ | |
-- requests/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getOneBeforeLast : List a -> Maybe a | |
getOneBeforeLast list = | |
case list of | |
[] -> Nothing | |
a :: _ :: [] -> Just a | |
_ :: a -> getOneBeforeLast a | |
-- getOneBeforeLast [1,2,3,4,5] == [4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Time exposing (Time) | |
-- 2017-01-22T17:18:02.921Z -> 2017-01-22T00:00:00.000Z | |
today : Time -> Time | |
today time = | |
time - (toFloat <| rem (round time) (round <| 24.0 * Time.hour)) |