From 9de4cbf68e671debe992e9b8c2454aef8961611a Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Mon, 19 Oct 2020 19:53:11 +1100 Subject: [PATCH 01/17] simplify identity signup function --- api/src/functions/identity-signup.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/api/src/functions/identity-signup.js b/api/src/functions/identity-signup.js index 9524495..acca039 100644 --- a/api/src/functions/identity-signup.js +++ b/api/src/functions/identity-signup.js @@ -1,4 +1,6 @@ -import { createUser } from 'src/services/users/users.js' +// import { createUser } from 'src/services/users/users.js' + +// identity-signup.js export const handler = async (req, _context) => { const body = JSON.parse(req.body) @@ -13,15 +15,15 @@ export const handler = async (req, _context) => { if (eventType === 'signup') { roles.push('user') - const hi = { - email: 'kurt.hutten@gmail.com', - image: '', - bio: '' - } - const input = { - email, - } - createUser({input}) + // const hi = { + // email: 'kurt.hutten@gmail.com', + // image: '', + // bio: '' + // } + // const input = { + // email, + // } + // createUser({input}) return { statusCode: 200, -- 2.39.5 From 69a760578b1b265039bdc8ad06b35f04a750e01c Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Tue, 20 Oct 2020 06:56:26 +1100 Subject: [PATCH 02/17] Save user to db on sign up --- api/src/functions/identity-signup.js | 53 +++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/api/src/functions/identity-signup.js b/api/src/functions/identity-signup.js index acca039..422d5a6 100644 --- a/api/src/functions/identity-signup.js +++ b/api/src/functions/identity-signup.js @@ -6,6 +6,49 @@ export const handler = async (req, _context) => { const body = JSON.parse(req.body) console.log(body) console.log(_context) + // DUMP FROM THE LOGS ABOVE + /* + 5:09:30 AM: 2020-10-19T18:09:30.011Z 9da27e24-b6ec-404e-8e7d-25b5d323b67a INFO { + event: 'signup', + instance_id: '403b7d63-17f9-48f1-a85f-3d6b41c7dad1', + user: { + id: '641222ee-3e61-4253-8c11-9f764779bcc5', + aud: '', + role: '', + email: 'k.hutten@protonmail.ch', + confirmation_sent_at: '2020-10-19T18:09:01Z', + app_metadata: { provider: 'email' }, + user_metadata: { full_name: 'sick_dog' }, + created_at: '2020-10-19T18:09:01Z', + updated_at: '2020-10-19T18:09:01Z' + } + } + 5:09:30 AM: 2020-10-19T18:09:30.011Z 9da27e24-b6ec-404e-8e7d-25b5d323b67a INFO { + callbackWaitsForEmptyEventLoop: [Getter/Setter], + succeed: [Function], + fail: [Function], + done: [Function], + functionVersion: '$LATEST', + functionName: 'ba7eb4948d1313283ebb91472c689d38444f07ae2f4278da925d3ce7f1d94e3c', + memoryLimitInMB: '1024', + logGroupName: '/aws/lambda/ba7eb4948d1313283ebb91472c689d38444f07ae2f4278da925d3ce7f1d94e3c', + logStreamName: '2020/10/19/[$LATEST]af6ff2c067da44268b4a0c9d1e4ca1ea', + clientContext: { + custom: { + netlify: 'eyJpZGVudGl0eSI6eyJ1cmwiOiJodHRwczovL2FuZ3J5LWRpamtzdHJhLTAzMWExMC5uZXRsaWZ5LmFwcC8ubmV0bGlmeS9pZGVudGl0eSIsInRva2VuIjoiZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmxlSEFpT2pFMk1ETXhNekV3TWprc0luTjFZaUk2SWpBaWZRLk54Q0hmb0I2aDRpc0V6NnpJREhWbThLTU5hcEZrb3g0dTFXS2dTemhzUncifSwic2l0ZV91cmwiOiJodHRwczovL2FuZ3J5LWRpamtzdHJhLTAzMWExMC5uZXRsaWZ5LmFwcCJ9' + }, + identity: { + url: 'https://angry-dijkstra-031a10.netlify.app/.netlify/identity', + token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDMxMzEwMjksInN1YiI6IjAifQ.NxCHfoB6h4isEz6zIDHVm8KMNapFkox4u1WKgSzhsRw' + } + }, + identity: undefined, + invokedFunctionArn: 'arn:aws:lambda:us-east-1:012533533302:function:ba7eb4948d1313283ebb91472c689d38444f07ae2f4278da925d3ce7f1d94e3c', + awsRequestId: '9da27e24-b6ec-404e-8e7d-25b5d323b67a', + getRemainingTimeInMillis: [Function: getRemainingTimeInMillis] + } + 5:09:30 AM: Duration: 5.78 ms Memory Usage: 69 MB Init Duration: 199.35 ms + */ const eventType = body.event const user = body.user @@ -20,10 +63,12 @@ export const handler = async (req, _context) => { // image: '', // bio: '' // } - // const input = { - // email, - // } - // createUser({input}) + const input = { + email, + bio: 'default bio' + // full_name: user.user_metadata.full_name + } + await createUser({input}) return { statusCode: 200, -- 2.39.5 From 4814093a7b638a69cb6848e6a4b035dc864804b6 Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Tue, 20 Oct 2020 07:28:22 +1100 Subject: [PATCH 03/17] Include files properly plus update the readme --- README.md | 36 +++++++++++++++++++--------- api/src/functions/identity-signup.js | 4 +--- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 69cbc06..7f7838f 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,38 @@ -# Redwood +# CadHub -> **WARNING:** RedwoodJS software has not reached a stable version 1.0 and should not be considered suitable for production use. In the "make it work; make it right; make it fast" paradigm, Redwood is in the later stages of the "make it work" phase. +CadHub aims to be a community website for javascript based code-cad. Currently trying to integrate [cascadeStudio](https://zalo.github.io/CascadeStudio/), but if successful plan to also integrate [jsCad](https://openjscad.org/). +OpenScad has proven code-cad a much loved formate for cad-modeling. Joining code-cad to a mature language like javascript that has a package manager (npm) plus a community hub for sharing cad models like CadHub, we're going to build a thriving community. ## Getting Started -- [Tutorial](https://redwoodjs.com/tutorial/welcome-to-redwood): getting started and complete overview guide. -- [Docs](https://redwoodjs.com/docs/introduction): using the Redwood Router, handling assets and files, list of command-line tools, and more. -- [Redwood Community](https://community.redwoodjs.com): get help, share tips and tricks, and collaborate on everything about RedwoodJS. -### Setup +Because we're integrating cascadeStudio, this is done some what crudely for the time being, so you'll need to clone the repo with submodules. -We use Yarn as our package manager. To get the dependencies installed, just do this in the root directory: +```terminal +git clone --recurse-submodules -j8 git@github.com:Irev-Dev/cadhub.git +# or +git clone --recurse-submodules -j8 https://github.com/Irev-Dev/cadhub.git +``` +Install dependencies ```terminal yarn install ``` -### Fire it up - +### Fire up dev ```terminal -yarn redwood dev +yarn rw dev ``` -Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on `http://localhost:8911` and are also proxied to `http://localhost:8910/.redwood/functions/*`. +Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on `http://localhost:8911` and are also proxied to `http://localhost:8910/.redwood/functions/*`. +### Note: +We're using [RedwoodJS](https://redwoodjs.com/), this is perhaps unwise since they haven't reached 1.0 yet, however with their aim to release 1.0 by the end of the year, it shouldn't be too difficult to port changes over the coming months. +If you not familiar with Redwood, never fear the main bit of tech it uses is React, Graphql(apollo) and serverless/lamdas, depending on what part of the app you want to help with, so long as you know you way around these bits of tech you should be fine with some light referencing of the RedWood docs + +### Extra Redwood docs, i.e. getting familiar with the frame work. +- [Tutorial](https://redwoodjs.com/tutorial/welcome-to-redwood): getting started and complete overview guide. +- [Docs](https://redwoodjs.com/docs/introduction): using the Redwood Router, handling assets and files, list of command-line tools, and more. +- [Redwood Community](https://community.redwoodjs.com): get help, share tips and tricks, and collaborate on everything about RedwoodJS. + +## Styles + +We're using tailwind utility classes so please try and use them as much as possible. Again if you not familiar, the [tailwind search](https://tailwindcss.com/) is fantastic, so searching for the css property you want to use will lead you to the correct class 99% of the time. diff --git a/api/src/functions/identity-signup.js b/api/src/functions/identity-signup.js index 422d5a6..a0dd70d 100644 --- a/api/src/functions/identity-signup.js +++ b/api/src/functions/identity-signup.js @@ -1,6 +1,4 @@ -// import { createUser } from 'src/services/users/users.js' - -// identity-signup.js +import { createUser } from 'src/services/users/users.js' export const handler = async (req, _context) => { const body = JSON.parse(req.body) -- 2.39.5 From 255f347e8e4e441ef460a80603c1d57bb4baa49f Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Tue, 20 Oct 2020 08:00:00 +1100 Subject: [PATCH 04/17] Remove auth from identity triggered lambda --- api/src/functions/identity-signup.js | 4 ++-- api/src/services/users/users.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/functions/identity-signup.js b/api/src/functions/identity-signup.js index a0dd70d..6b52938 100644 --- a/api/src/functions/identity-signup.js +++ b/api/src/functions/identity-signup.js @@ -1,4 +1,4 @@ -import { createUser } from 'src/services/users/users.js' +import { createUserInsecure } from 'src/services/users/users.js' export const handler = async (req, _context) => { const body = JSON.parse(req.body) @@ -66,7 +66,7 @@ export const handler = async (req, _context) => { bio: 'default bio' // full_name: user.user_metadata.full_name } - await createUser({input}) + await createUserInsecure({input}) return { statusCode: 200, diff --git a/api/src/services/users/users.js b/api/src/services/users/users.js index f3875f8..3d3675c 100644 --- a/api/src/services/users/users.js +++ b/api/src/services/users/users.js @@ -14,9 +14,11 @@ export const user = ({ id }) => { } export const createUser = ({ input }) => { - console.log(input) - console.log(JSON.stringify(input)) requireAuth({ role: 'admin' }) + return createUserInsecure({input}) +} + +export const createUserInsecure = ({ input }) => { return db.user.create({ data: input, }) -- 2.39.5 From dcadd20d622a251554b74e58096e5704903715ef Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Tue, 20 Oct 2020 20:09:52 +1100 Subject: [PATCH 05/17] Readme and submodule tweaks --- README.md | 4 ++++ web/src/cascade | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f7838f..109f527 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ yarn rw dev ``` Your browser should open automatically to `http://localhost:8910` to see the web app. Lambda functions run on `http://localhost:8911` and are also proxied to `http://localhost:8910/.redwood/functions/*`. + +You may need to register a account depending on what issue you are trying to tackle, This can be done by clicking the login button on the top right. +(some routes are protected, but permissions is a big area that needs a lot of work in the near future, so it's in a very incomplete state atm) + ### Note: We're using [RedwoodJS](https://redwoodjs.com/), this is perhaps unwise since they haven't reached 1.0 yet, however with their aim to release 1.0 by the end of the year, it shouldn't be too difficult to port changes over the coming months. If you not familiar with Redwood, never fear the main bit of tech it uses is React, Graphql(apollo) and serverless/lamdas, depending on what part of the app you want to help with, so long as you know you way around these bits of tech you should be fine with some light referencing of the RedWood docs diff --git a/web/src/cascade b/web/src/cascade index e634591..62f9612 160000 --- a/web/src/cascade +++ b/web/src/cascade @@ -1 +1 @@ -Subproject commit e634591e27dd41fec1638b278be3c298c6ab4b5a +Subproject commit 62f961293d72558e59cdcbe0707ef15a06d30c12 -- 2.39.5 From af44e2afdbaba8f542847441bf1919e4e3a7e0c2 Mon Sep 17 00:00:00 2001 From: Linus Johansson Date: Tue, 20 Oct 2020 19:41:37 +0200 Subject: [PATCH 06/17] Page title changed from default to CadHub --- web/src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/index.html b/web/src/index.html index a8fa947..2ca926a 100644 --- a/web/src/index.html +++ b/web/src/index.html @@ -4,7 +4,7 @@ - <%= htmlWebpackPlugin.options.title %> + CadHub