Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vercel accounts server #29

Merged
merged 8 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/accounts-client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": [
"next/core-web-vitals",
"coldsurfers", // for nodejs-typescript, or 'coldsurfers/nodejs-typescript'
"coldsurfers/react-typescript" // for react-typescript
],
"rules": {
"import/extensions": "off",
"import/no-unresolved": "off",
"no-undef": "off"
}
}
36 changes: 36 additions & 0 deletions packages/accounts-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

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

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
6 changes: 6 additions & 0 deletions packages/accounts-client/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
36 changes: 36 additions & 0 deletions packages/accounts-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
32 changes: 32 additions & 0 deletions packages/accounts-client/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @type {import('next').NextConfig} */

const path = require('path')

const nextConfig = {
experimental: {
externalDir: true,
},
webpack: (config) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
'react-native$': 'react-native-web',
'styled-components': path.resolve(__dirname, './node_modules/styled-components'),
}
config.resolve.extensions = [
'.web.js',
'.web.jsx',
'.web.ts',
'.web.tsx',
...config.resolve.extensions,
]

return config
},
transpilePackages: ['@coldsurfers/hotsurf'],
compiler: {
styledComponents: true,
},
};

module.exports = nextConfig;
44 changes: 44 additions & 0 deletions packages/accounts-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "accounts-client",
"version": "0.1.0",
"private": true,
"workspaces": {
"nohoist": [
"**"
]
},
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint --fix"
},
"dependencies": {
"next": "14.1.0",
"react": "^18",
"react-dom": "^18",
"react-native-web": "^0.18.12",
"@coldsurfers/hotsurf": "0.2.6",
"styled-components": "6.1.8",
"react-native": "^0.70.6",
"fstvllife-design-system": "0.2.7-rc.1"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.53.0",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-coldsurfers": "^1.1.3",
"eslint-config-next": "14.1.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.2.4",
"typescript": "^5"
}
}
1 change: 1 addition & 0 deletions packages/accounts-client/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/accounts-client/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/accounts-client/src/app/favicon.ico
Binary file not shown.
28 changes: 28 additions & 0 deletions packages/accounts-client/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import type { Metadata } from 'next'
import StyledComponentsRegistry from '../registry/StyledComponentsRegistry'
import StyleSheetRegistry from '../registry/StyleSheetRegistry'
import StyledRegistry from '../registry/StyledComponentsRegistry'

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode
}>) {
return (
<html lang="en">
<body>
<StyledComponentsRegistry>
<StyleSheetRegistry>
{children}
</StyleSheetRegistry>
</StyledComponentsRegistry>
</body>
</html>
)
}
30 changes: 30 additions & 0 deletions packages/accounts-client/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client'

import {Button, LoginForm} from 'fstvllife-design-system'
import styled from 'styled-components'

const Wrapper = styled.section`
position: absolute;
top: 50%; /* position the top edge of the element at the middle of the parent */
left: 50%; /* position the left edge of the element at the middle of the parent */

transform: translate(-50%, -50%);

padding: 1rem;
border-radius: 3px;

display: flex;
flex-direction: column;

box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
`


export default function Home() {
return (
<Wrapper>
<LoginForm formTitle="ColdSurf Accounts" onPressLoginButton={() => {}} />
</Wrapper>
)
}
17 changes: 17 additions & 0 deletions packages/accounts-client/src/registry/StyleSheetRegistry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-nocheck
'use client'
import { useServerInsertedHTML } from 'next/navigation'
import { StyleSheet } from 'react-native'

export default function StyleSheetRegistry({ children }: { children: React.ReactNode }) {
useServerInsertedHTML(() => {
const sheet = StyleSheet.getSheet()
return (
<style
dangerouslySetInnerHTML={{ __html: sheet.textContent }}
id={sheet.id}
/>
)
})
return <>{children}</>
}
29 changes: 29 additions & 0 deletions packages/accounts-client/src/registry/StyledComponentsRegistry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use client'

import React, { useState } from 'react'
import { useServerInsertedHTML } from 'next/navigation'
import { ServerStyleSheet, StyleSheetManager } from 'styled-components'

export default function StyledComponentsRegistry({
children,
}: {
children: React.ReactNode
}) {
// Only create stylesheet once with lazy initial state
// x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet())

useServerInsertedHTML(() => {
const styles = styledComponentsStyleSheet.getStyleElement()
styledComponentsStyleSheet.instance.clearTag()
return <>{styles}</>
})

if (typeof window !== 'undefined') return <>{children}</>

return (
<StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
{children}
</StyleSheetManager>
)
}
31 changes: 31 additions & 0 deletions packages/accounts-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// "extends": ["../../tsconfig.paths.json"],
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"react": ["./node_modules/@types/react"],
"@app/*": ["./packages/accounts-client/app/*"],
"@hooks/*": ["./packages/accounts-client/hooks/*"],
"@utils/*": ["./packages/accounts-client/utils/*"],
"@ui/*": ["./packages/accounts-client/ui/*"],
},
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
5 changes: 4 additions & 1 deletion packages/accounts-server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ dist/
src/config/config.json
.env
public/
.eslintcache
.eslintcache
.vercel

src/prisma/schema.prisma
21 changes: 14 additions & 7 deletions packages/accounts-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@
"version": "1.0.0",
"private": true,
"license": "MIT",
"workspaces": {
"nohoist": [
"**"
]
},
"scripts": {
"debug": "vercel dev --listen 3001",
"prebuild": "yarn workspace @coldsurfers/mailer-utils build && yarn workspace @coldsurfers/shared-utils build && yarn workspace @coldsurfers/accounts-schema build",
"build": "rm -rf dist && tsc --project ./tsconfig.build.json && cp -R ./src/config ./dist/config",
"db:generate": "yarn prisma format --schema ../../prisma/schema.prisma && yarn prisma generate --schema ../../prisma/schema.prisma",
"db:push": "yarn prisma db push --schema ../../prisma/schema.prisma",
"deploy": "yarn pm2 start ./src/config/ecosystem.config.js",
"dev": "NODE_ENV=development ts-node ./src/server.ts",
"postinstall": "yarn db:generate",
"prisma:copy": "cp -r ../../prisma/schema.prisma ./src/prisma/schema.prisma",
"prisma:generate": "yarn prisma generate --schema ./src/prisma/schema.prisma",
"postinstall": "yarn prisma:copy && yarn prisma:generate",
"lint": "eslint --cache \"src/**/*.{js,jsx,ts,tsx}\"",
"lint:fix": "yarn lint --fix",
"start": "NODE_ENV=production node ./dist/server.js"
"start": "NODE_ENV=production node ./dist/server.js",
"unlink:coldsurfers": "unlink node_modules/@coldsurfers/accounts-schema && cp -R ../accounts-schema node_modules/@coldsurfers/accounts-schema && unlink node_modules/@coldsurfers/mailer-utils && cp -R ../mailer-utils node_modules/@coldsurfers/mailer-utils && unlink node_modules/@coldsurfers/shared-utils && cp -R ../mailer-utils node_modules/@coldsurfers/shared-utils"
},
"dependencies": {
"@coldsurfers/accounts-schema": "1.0.1-rc.4",
"@coldsurfers/mailer-utils": "1.0.0",
"@coldsurfers/shared-utils": "^1.0.1-rc.0",
"@coldsurfers/accounts-schema": "1.0.1-rc.4",
"@fastify/autoload": "^5.8.0",
"@fastify/cors": "^8.5.0",
"@fastify/jwt": "^7.2.4",
"@prisma/client": "5.8.0",
"@vercel/node": "^2.8.2",
"crypto-js": "^4.2.0",
"dotenv": "^16.0.3",
"fastify": "^4.25.2",
"google-auth-library": "^9.4.1",
"nconf": "^0.12.1",
"nodemailer": "^6.9.8",
"nodemailer-smtp-transport": "^2.7.4",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/crypto-js": "^4.2.1",
"@types/nconf": "^0.10.6",
"@types/node": "^20.10.6",
"@types/nodemailer": "^6.4.14",
"@types/nodemailer-smtp-transport": "^2.7.8",
Expand Down
Loading
Loading