Skip to content

Commit

Permalink
chore: new project structure (#8)
Browse files Browse the repository at this point in the history
* chore: new project structure

* docs: add README.md
  • Loading branch information
Dolu89 authored Feb 13, 2023
1 parent 9a0e7b1 commit 0d7f862
Show file tree
Hide file tree
Showing 67 changed files with 10,207 additions and 2,189 deletions.
44 changes: 44 additions & 0 deletions .adonisrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"typescript": true,
"commands": [
"./commands",
"@adonisjs/core/build/commands/index.js",
"@adonisjs/repl/build/commands"
],
"exceptionHandlerNamespace": "App/Exceptions/Handler",
"aliases": {
"App": "app",
"Config": "config",
"Database": "database",
"Contracts": "contracts"
},
"preloads": ["./start/routes", "./start/kernel"],
"providers": [
"./providers/AppProvider",
"@adonisjs/core",
"@adonisjs/session",
"@adonisjs/view",
"@adonisjs/shield"
],
"metaFiles": [
{
"pattern": "public/**",
"reloadServer": false
},
{
"pattern": "resources/views/**/*.edge",
"reloadServer": false
}
],
"aceProviders": ["@adonisjs/repl"],
"tests": {
"suites": [
{
"name": "functional",
"files": ["tests/functional/**/*.spec(.ts|.js)"],
"timeout": 60000
}
]
},
"testProviders": ["@japa/preset-adonis/TestsProvider"]
}
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Adonis default .gitignore ignores
node_modules
build
coverage
.vscode
.DS_STORE
.env
tmp

# Additional .gitignore ignores (any custom file you wish)
.idea

# Additional good to have ignores for dockerignore
Dockerfile*
docker-compose*
.dockerignore
*.md
.git
.gitignore
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
12 changes: 9 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
PROXY_URL=wss://your-proxy.com
RELAYS=wss://relay1.com,wss://relay2.com,wss://relay.com
REDIS=redis://user:password@localhost:6379
PORT=3333
HOST=0.0.0.0
NODE_ENV=development
APP_KEY=nP8HxRzja-sysBG6rn155do38mWGa9ZQ
DRIVE_DISK=local
SESSION_DRIVER=cookie
CACHE_VIEWS=false
PROXY_URL=wss://nproxy.zerologin.co
RELAYS=wss://nostr.v0l.io,wss://relay.nostr.bg,wss://relay.damus.io,wss://nostr-pub.wellorder.net,wss://nostr.zebedee.cloud,wss://nostr.openchain.fr,wss://nostr.bitcoiner.social,wss://nostr-pub.semisol.dev/,wss://nos.lol
3 changes: 3 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NODE_ENV=test
ASSETS_DRIVER=fake
SESSION_DRIVER=memory
68 changes: 4 additions & 64 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,67 +1,7 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# 0x
profile-*

# mac files
.DS_Store

# vim swap files
*.swp

# webstorm
.idea

# vscode
build
coverage
.vscode
*code-workspace

# clinic
profile*
*clinic*
*flamegraph*

# generated code
examples/typescript-server.js
test/types/index.js

# compiled app
dist

.DS_STORE
.env
tmp
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
4 changes: 0 additions & 4 deletions .taprc

This file was deleted.

28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG NODE_IMAGE=node:16.13.1-alpine

FROM $NODE_IMAGE AS base
RUN apk --no-cache add dumb-init curl python3 make gcc g++
RUN mkdir -p /home/node/app && chown node:node /home/node/app
WORKDIR /home/node/app
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
USER node
RUN mkdir tmp

FROM base AS dependencies
COPY --chown=node:node ./package.json ./
COPY --chown=node:node ./pnpm-lock.yaml ./
RUN pnpm install
COPY --chown=node:node . .

FROM dependencies AS build
RUN node ace build --production --ignore-ts-errors

FROM base AS production
ENV NODE_ENV=production
ENV PORT=$PORT
ENV HOST=0.0.0.0
COPY --chown=node:node ./package*.json ./
RUN pnpm install --prod
COPY --chown=node:node --from=build /home/node/app/build .
EXPOSE $PORT
CMD [ "dumb-init", "node", "server.js" ]
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,44 @@ In the project directory, run:
pnpm install
```

Edit your env variables. You can use a `.env` file by copying the file `.env.example` in the root directory, or you can set your variables into your hosting provider UI.
Edit your env variables. You can use a `.env` file by copying the file `.env.example` in the root directory, or you can set your variables into your hosting provider UI.\
For `APP_KEY`, you can use the following command to generate one `node ace generate:key`

```
PORT=3333
HOST=0.0.0.0
NODE_ENV=development
APP_KEY=unique-key
DRIVE_DISK=local
SESSION_DRIVER=cookie
CACHE_VIEWS=false
PROXY_URL=wss://your-proxy.com
RELAYS=wss://relay1.com,wss://relay2.com,wss://relay.com
```

## Launch

### `npm run dev`
### Development

To start the app in dev mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.\
Use `ws://localhost:3000` into your Nostr client.
`npm run dev` to start the app in dev mode.\
Open [http://localhost:3333](http://localhost:3333) to view it in the browser.\
Use `ws://localhost:3333` into your Nostr client.

### `npm start`
### Production

For production mode
```
npm run build
cd build
pnpm install --prod
node server.js
```

### `npm run test` (TODO)
### Running tests

Run the test cases.
TODO

## Known issues
- Global feed don't load after the cache is removed
- NOTICE is not send to the right client
- Sometimes the proxy runs out of memory. Please help.

## Learn More

Expand Down
16 changes: 16 additions & 0 deletions ace
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
|--------------------------------------------------------------------------
| Ace Commands
|--------------------------------------------------------------------------
|
| This file is the entry point for running ace commands.
|
*/

require('reflect-metadata')
require('source-map-support').install({ handleUncaughtExceptions: false })

const { Ignitor } = require('@adonisjs/core/build/standalone')
new Ignitor(__dirname)
.ace()
.handle(process.argv.slice(2))
101 changes: 101 additions & 0 deletions ace-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"commands": {
"dump:rcfile": {
"settings": {},
"commandPath": "@adonisjs/core/build/commands/DumpRc",
"commandName": "dump:rcfile",
"description": "Dump contents of .adonisrc.json file along with defaults",
"args": [],
"aliases": [],
"flags": []
},
"list:routes": {
"settings": {
"loadApp": true,
"stayAlive": true
},
"commandPath": "@adonisjs/core/build/commands/ListRoutes/index",
"commandName": "list:routes",
"description": "List application routes",
"args": [],
"aliases": [],
"flags": [
{
"name": "verbose",
"propertyName": "verbose",
"type": "boolean",
"description": "Display more information"
},
{
"name": "reverse",
"propertyName": "reverse",
"type": "boolean",
"alias": "r",
"description": "Reverse routes display"
},
{
"name": "methods",
"propertyName": "methodsFilter",
"type": "array",
"alias": "m",
"description": "Filter routes by method"
},
{
"name": "patterns",
"propertyName": "patternsFilter",
"type": "array",
"alias": "p",
"description": "Filter routes by the route pattern"
},
{
"name": "names",
"propertyName": "namesFilter",
"type": "array",
"alias": "n",
"description": "Filter routes by route name"
},
{
"name": "json",
"propertyName": "json",
"type": "boolean",
"description": "Output as JSON"
},
{
"name": "table",
"propertyName": "table",
"type": "boolean",
"description": "Output as Table"
},
{
"name": "max-width",
"propertyName": "maxWidth",
"type": "number",
"description": "Specify maximum rendering width. Ignored for JSON Output"
}
]
},
"generate:key": {
"settings": {},
"commandPath": "@adonisjs/core/build/commands/GenerateKey",
"commandName": "generate:key",
"description": "Generate a new APP_KEY secret",
"args": [],
"aliases": [],
"flags": []
},
"repl": {
"settings": {
"loadApp": true,
"environment": "repl",
"stayAlive": true
},
"commandPath": "@adonisjs/repl/build/commands/AdonisRepl",
"commandName": "repl",
"description": "Start a new REPL session",
"args": [],
"aliases": [],
"flags": []
}
},
"aliases": {}
}
Loading

0 comments on commit 0d7f862

Please sign in to comment.