# Installing the serverless cli
npm install -g serverless
# Updating serverless from a previous version of serverless
npm install -g serverless
# Login to the serverless platform (optional)
serverless login
serverless config credentials --provider aws --key YOUR_ACCESS_KEY --secret YOUR_SECRET_KEY
This file contains 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 { ApolloServer, gql } from 'apollo-server-lambda'; | |
const typeDefs = gql` | |
type Query { | |
hello: String | |
} | |
`; | |
const resolvers = { | |
Query : { |
This file contains 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 * as redis from 'redis' | |
import { promisify } from 'util'; | |
import { Comment } from './types' | |
const redisOptions = { | |
host: process.env.redisHost, | |
port: process.env.redisPort, | |
} | |
let client; |
This file contains 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 { Comment } from './types'; | |
import { ICommentStorage, CommentStorage } from './comment.storage'; | |
export interface ICommentService { | |
getComments(itemId: string): Promise<[Comment]>; | |
addComments(itemId: string, userId: string, content: string): Promise<[Comment]>; | |
editComments(itemId: string, msgId: number, userId: string, content: string): Promise<[Comment]>; | |
deleteComments(itemId: string, msgId: number, userId: string): Promise<[Comment]>; |
This file contains 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
export interface Comment { | |
msgId: number, | |
userId: string, | |
content: string, | |
createdAt: number, | |
deleted: Boolean | |
} |
This file contains 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 { ApolloServer, gql } from 'apollo-server-lambda'; | |
import { CommentService } from './comment.service'; | |
const typeDefs = gql` | |
type Comment{ | |
msgId: Int | |
userId : String | |
content : String | |
createdAt : String | |
deleted : Boolean |
This file contains 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
service: | |
name: aws-typescript-graphql-tuto | |
# Add the serverless-webpack plugin | |
plugins: | |
- serverless-webpack | |
- serverless-offline | |
provider: | |
name: aws |