Skip to content

Commit

Permalink
Adding new fullstack application into demos
Browse files Browse the repository at this point in the history
  • Loading branch information
mzkrasner committed Apr 23, 2024
1 parent 0100508 commit 38d0e16
Show file tree
Hide file tree
Showing 27 changed files with 16,202 additions and 300 deletions.
22 changes: 22 additions & 0 deletions demo/fullstack-app/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# When adding additional environment variables, the schema in "/src/env.js"
# should be updated accordingly.

# Next Auth
# You can generate a new secret on the command line with:
# openssl rand -base64 32
# https://next-auth.js.org/configuration/options#secret
# NEXTAUTH_SECRET=""
NEXTAUTH_URL="http://localhost:3000" # You can leave this as-is if running locally
NEXTAUTH_SECRET=""

# Next Auth Discord Provider (https://discord.com/developers/applications)
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""

# Private Key for Static Ceramic DID
CERAMIC_PRIVATE_KEY=""

# Special Aggregation Model ID (you can leave this as-is)
AGGREGATION_ID="kjzl6hvfrbw6ca1wj8fcgf6m3fb3ntmq7ppvyobaqjqg6jdsk0q45mcf9m5x4ri"


42 changes: 42 additions & 0 deletions demo/fullstack-app/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @type {import("eslint").Linter.Config} */
const config = {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked"
],
"rules": {
"@typescript-eslint/array-type": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/consistent-type-imports": [
"warn",
{
"prefer": "type-imports",
"fixStyle": "inline-type-imports"
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": {
"attributes": false
}
}
]
}
}
module.exports = config;
39 changes: 39 additions & 0 deletions demo/fullstack-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# database
/prisma/db.sqlite
/prisma/db.sqlite-journal

# next.js
/.next/
/out/
next-env.d.ts

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
5 changes: 5 additions & 0 deletions demo/fullstack-app/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
19 changes: 19 additions & 0 deletions demo/fullstack-app/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
63 changes: 63 additions & 0 deletions demo/fullstack-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Points Demo Application

A simple demo application designed to illustrate a straightforward way to consume the [Ceramic Points Library](https://www.npmjs.com/package/@ceramic-solutions/points?activeTab=readme). Seeing as the points library was built for developers and communities who might want to reward their participants for favorable behaviors (such as engagement on social platforms or meaningful contributions), this example application plays on this use case.

In this example, we will be using the points library to reward points to users for joining the Ceramic Discord server.

## Dependencies

In order to run this example locally, you will need to create a copy of the [.env.example](.env.example) file in the root of this directory, rename it to `.env`, and begin loading the file with active corresponding values. These include the following:

**NEXTAUTH_SECRET**

We will be using [NextAuth](https://next-auth.js.org/) as our open-source authentication solution (in order to verify Discord server membership). You can create a secret easily by running the following in your terminal:

```bash
openssl rand -base64 32
```

**DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET**

This app will use Discord as the authentication provider (wrapped by NextAuth). To obtain these credentials, navigate to the [Discord Developer Portal](https://discord.com/developers/applications) and set up a new application. On the left-hand panel, click on "OAuth2" and bring over your Client ID and Client Secret from the "Client Information" box.

Finally, since you'll be running the application locally, set the following URI value within the "Redirects" box (found under "Client Information"): `http://localhost:3000/api/auth/callback/discord`.

**CERAMIC_PRIVATE_KEY**

This is the private key your application will use to instantiate a static key:did in order to write points using the library. This DID will act as the identifier for the issuer of points for your application (you).

If you have the [ComposeDB CLI](https://composedb.js.org/docs/0.7.x/api/modules/cli) installed globally, you can run the following command in your terminal to create one:

```bash
composedb did:generate-private-key
```

**AGGREGATION_ID**

A default value for this environment variable has been provided for you within the [.env.example](.env.example) file. Please leave this as-is.

**PROJECT_ID**

We will be using [WalletConnect's](https://walletconnect.com/) Web3Modal for Web3 authentication. In your [_app.tsx](./src/pages/_app.tsx) file, you will need to enter an active value for the `PROJECT_ID` constant defined on line 10.

You can set up a developer account for free by visiting [cloud.walletconnect.com](https://cloud.walletconnect.com/sign-in). Once authenticated, create a new app and copy over the "Project ID" value (found in the dashboard view for that corresponding app).

## Getting Started

Once you've completed the steps above, you're ready to get started experimenting with the application in developer mode.

First, install your dependencies:

```bash
pnpm install
```

Once installed, run the application in developer mode:

```bash
pnpm dev
```

## License

Dual licensed under MIT and Apache 2
18 changes: 18 additions & 0 deletions demo/fullstack-app/composites/sandboxAggregation.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# (for reference only)

interface PointsAggregationInterface @loadModel(id: "kjzl6hvfrbw6cb6393dpd8blke5w8r7pvbl4449mxetuibcav3oab8fnxmys6d6") {
id: ID!
}

type SandboxPointAggregation implements PointsAggregationInterface # Deployed model ID: kjzl6hvfrbw6ca1wj8fcgf6m3fb3ntmq7ppvyobaqjqg6jdsk0q45mcf9m5x4ri
@createModel(
description: "Aggregation of multiple Ceramic Sandbox read points to an account"
accountRelation: SET
accountRelationFields: ["recipient", "context"]
) {
issuer: DID! @documentAccount
recipient: DID! @accountReference
points: Int!
date: DateTime!
context: String! @string(maxLength: 100)
}
22 changes: 22 additions & 0 deletions demo/fullstack-app/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
await import("./src/env.js");

/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,

/**
* If you are using `appDir` then you must comment the below `i18n` config out.
*
* @see https://github.com/vercel/next.js/issues/41980
*/
i18n: {
locales: ["en"],
defaultLocale: "en",
},
};

export default config;
54 changes: 54 additions & 0 deletions demo/fullstack-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@ceramic-solutions/fullstack-demo",
"version": "0.1.0",
"private": true,
"author": "3Box Labs",
"license": "(Apache-2.0 OR MIT)",
"repository": {
"type": "git",
"url": "https://github.com/ceramicstudio/solutions-sdk",
"directory": "demo/fullstack-app"
},
"type": "module",
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
},
"dependencies": {
"@t3-oss/env-nextjs": "^0.9.2",
"next": "^14.2.1",
"next-auth": "^4.24.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"viem": "^1.12.2",
"wagmi": "^1.4.2",
"react-device-detect": "^2.2.3",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/eslint": "^8.56.2",
"@types/node": "^20.11.20",
"@ceramic-solutions/key-did": "workspace:^",
"@ceramic-solutions/points": "workspace:^",
"uint8arrays": "^5.0.3",
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@composedb/types": "^0.7.1",
"@web3modal/wagmi": "^3.0.1",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.3",
"postcss": "^8.4.34",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1",
"typescript": "^5.4.2"
},
"ct3aMetadata": {
"initVersion": "7.30.2"
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit 38d0e16

Please sign in to comment.