Serverless forum software
Table of contents
-
Clone
git clone git@github.com:JustServerless/discuss.gitto your local machine. -
Run
cd discussto change directory. -
Run
npm installto install all necessary NPM dependencies for the Serverless project. -
Run
serverless project initto initialize the Serverless project. -
Add the following environment variables to the JSON array of the corresponding file in
_meta/variables. (e.g. in_meta/variables/s-variables-common.json)
{
...
"authTokenSecret": "STRONGVALUE"
}
-
Run
cd backend/lib && npm install && cd ../../to install the NPM dependencies for the GraphQL backend. -
Run
serverless dash deployand select endpoint and function to deploy the CORS enabled endpoint and function.
-
Run
cd client/src && npm installtin install the NPM dependencies for the client. -
Replace the
API_URLinclient/src/app/js/actions/index.jswith your deployed endpoint (the root of the endpoint) without thegraphqlstring at the end. -
Run
npm start(in the client/src folder) to run the client locally. The client is available in your browser athttp://localhost:8080/ -
Edit
s-project.jsonand changebucketName. Runnpm run buildto build the client -
Run
serverless client deployto host the frontend with the help of an S3 bucket
Connect to the graphql endpoint of the API (e.g. http://example.com/graphql) and a run the query as the query parameter against it.
mutation signUp {
signUp (
email: "test@example.com"
username: "test"
password: "12345678"
)
{
id
email
username
createdAt
updatedAt
}
}
mutation signIn {
signIn (
email: "test@example.com"
password: "12345678"
)
{
id
email
username
createdAt
updatedAt
jwt
}
}
{
users {
id
email
username
createdAt
updatedAt
}
}
{
user(id: "id") {
id
email
username
createdAt
updatedAt
}
}
mutation updateCurrentUser {
updateCurrentUser(
email: "new@example.com"
username: "New username"
password: "New password"
jwt: "jwtToken"
)
{
id
username
email
createdAt
updatedAt
}
}
mutation deleteCurrentUser {
deleteCurrentUser (
jwt: "jwtToken"
)
{
id
username
email
createdAt
updatedAt
}
}
mutation createPost {
createPost (
title: "Title"
body: "Body"
jwt: "jwtToken"
)
{
id
title
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
comments {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
}
{
posts {
id
title
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
comments {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
}
{
post(id: "id") {
id
title
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
comments {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
}
mutation updatePost {
updatePost(
id: "id"
title: "New title"
body: "New body"
jwt: "jwtToken"
)
{
id
title
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
comments {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
}
mutation deletePost {
deletePost (
id: "id"
jwt: "jwtToken"
)
{
id
title
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
comments {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
}
mutation createComment {
createComment (
body: "Body"
postId: "postId"
jwt: "jwtToken"
)
{
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
{
comments {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
{
comment(id: "id") {
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
mutation updateComment {
updateComment(
id: "id"
body: "New body"
jwt: "jwtToken"
)
{
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
mutation deleteComment {
deleteComment (
id: "id"
jwt: "jwtToken"
)
{
id
body
createdAt
updatedAt
author {
id
username
email
createdAt
updatedAt
}
}
}
