Skip to content

Instantly share code, notes, and snippets.

View stemmlerjs's full-sized avatar

Khalil Stemmler stemmlerjs

View GitHub Profile
export class AWSS3Uploader implements IUploader {
private s3: AWS.S3;
public config: S3UploadConfig;
...
private createDestinationFilePath(
fileName: string,
mimetype: string,
encoding: string
resolvers: {
...
Mutation: {
singleUpload: s3Uploader.singleFileUploadResolver.bind(s3Uploader)
}
}
import { AWSS3Uploader } from './s3'
const s3Uploader = new AWSS3Uploader({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
destinationBucketName: 'my-really-cool-bucket'
});
export class AWSS3Uploader implements IUploader {
private s3: AWS.S3;
public config: S3UploadConfig;
constructor(config: S3UploadConfig) {
AWS.config = new AWS.Config();
AWS.config.update({
region: config.region || "ca-central-1",
accessKeyId: config.accessKeyId,
secretAccessKey: config.secretAccessKey
export type File = {
filename: string;
mimetype: string;
encoding: string;
stream?: ReadStream;
}
export type UploadedFileResponse = {
filename: string;
mimetype: string;
import AWS from "aws-sdk";
type S3UploadConfig = {
accessKeyId: string;
secretAccessKey: string;
destinationBucketName: string;
region?: string;
};
export class AWSS3Uploader {
@stemmlerjs
stemmlerjs / server.ts
Created February 13, 2020 16:41
Another Apollo Server but with uploads enabled
import { ApolloServer, gql } from 'apollo-server'
const server = new ApolloServer({
typeDefs: gql`
type Query {
hello: String!
}
type UploadedFileResponse {
@stemmlerjs
stemmlerjs / server.ts
Created February 13, 2020 16:39
Basic Apollo Server
import { ApolloServer, gql } from 'apollo-server'
const server = new ApolloServer({
typeDefs: gql`
type Query {
hello: String!
}
`,
@stemmlerjs
stemmlerjs / studyspots.gql
Created February 1, 2020 01:09
Studyspots schema
enum SpotType {
Bar,
Restaurant,
Cafe,
Mall
}
enum SoundType {
Chatter,
@stemmlerjs
stemmlerjs / schema.graphql
Created November 8, 2019 15:51
Federation Example #3 - The resulting schema for User computed from Accounts and Reviews services
"""
Here's what the resulting User type looks like
"""
type User {
"A globally unique id for the user"
id: ID!
"The user's full name as provided"
name: String
"The account username of the user"