Skip to content

Commit cdf12e8

Browse files
committed
edited c sharp sample to be more clear
0 parents  commit cdf12e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+13276
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
FROM mcr.microsoft.com/devcontainers/typescript-node:22-bookworm

.devcontainer/devcontainer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"context": ".."
5+
},
6+
"features": {
7+
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
9+
"ghcr.io/devcontainers/features/aws-cli:1": {}
10+
}
11+
}

.github/workflows/deploy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
environment: playground
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
steps:
17+
- name: Checkout Repo
18+
uses: actions/checkout@v4
19+
20+
- name: Deploy
21+
uses: DefangLabs/[email protected]

.gitignore

Whitespace-only changes.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Sails.js & PostgreSQL
2+
3+
[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-sailsjs-postgres-template%26template_owner%3DDefangSamples)
4+
5+
This sample project demonstrates how to deploy
6+
7+
Sailsjs with Defang and connect it to a Postgres database. Furthermore, we emonstrate how to run a local Postgres container during development vs a managed postgres service (Neon). For a quick database set up please go to [Neon](https://neon.tech/) and follow set up instructions. The sample starts with a no tasks in the database and allows us to add tasks on the fly. It sets wide open permissions on the tables as well so you can start querying or mutating the data right away.
8+
9+
## Prerequisites
10+
11+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
12+
2. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account
13+
3. (Optional - for local development) [Docker CLI](https://docs.docker.com/engine/install/)
14+
4. (Optional) [Neon CLI] (https://neon.tech/docs/reference/neon-cli)
15+
16+
## Deploying production
17+
18+
1. Open the terminal and type `defang login`
19+
2. Add your connection string for the third party postgres database in the DATABASE_URL part of the compose.yaml section
20+
3. Type `defang compose up` in the CLI.
21+
4. Your app will be running within a few minutes.
22+
23+
## Development
24+
25+
For development, we use a Postgres container. The Postgres container is defined in the `compose.dev.yaml` file. The Neon postgres container is defined in the `compose.yaml` file, with some overrides in the `compose.dev.yaml` file so it correctly connects to the development database container. To start your own, please have the env variables, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB`, and `SESSION_SECRET` ready.
26+
27+
To start the development environment, run:
28+
29+
```
30+
docker compose -f compose.dev.yaml up --build
31+
```
32+
33+
---
34+
35+
Title: Sails.js & PostgreSQL
36+
37+
Short Description: A sample project demonstrating how to deploy a project with PostgreSQL and Sails.js.
38+
39+
Tags: PostgreSQL, Sails.js, SQL, JavaScript
40+
41+
Languages: nodejs

app/.editorconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
################################################
2+
# ╔═╗╔╦╗╦╔╦╗╔═╗╦═╗┌─┐┌─┐┌┐┌┌─┐┬┌─┐
3+
# ║╣ ║║║ ║ ║ ║╠╦╝│ │ ││││├┤ ││ ┬
4+
# o╚═╝═╩╝╩ ╩ ╚═╝╩╚═└─┘└─┘┘└┘└ ┴└─┘
5+
#
6+
# > Formatting conventions for your Sails app.
7+
#
8+
# This file (`.editorconfig`) exists to help
9+
# maintain consistent formatting throughout the
10+
# files in your Sails app.
11+
#
12+
# For the sake of convention, the Sails team's
13+
# preferred settings are included here out of the
14+
# box. You can also change this file to fit your
15+
# team's preferences (for example, if all of the
16+
# developers on your team have a strong preference
17+
# for tabs over spaces),
18+
#
19+
# To review what each of these options mean, see:
20+
# http://editorconfig.org/
21+
#
22+
################################################
23+
root = true
24+
25+
[*]
26+
indent_style = space
27+
indent_size = 2
28+
end_of_line = lf
29+
charset = utf-8
30+
trim_trailing_whitespace = true
31+
insert_final_newline = true

app/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DATABASE_URL=postgresql://tasklistdb_owner:[email protected]/tasklistdb?sslmode=require
2+
SESSION_SECRET=91cc809104bca25c3dd96590124ee598
3+
NODE_ENV=production

app/.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
assets/dependencies/**/*.js
2+
views/**/*.ejs
3+

app/.eslintrc

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐
3+
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│
4+
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘
5+
// A set of basic code conventions designed to encourage quality and consistency
6+
// across your Sails app's code base. These rules are checked against
7+
// automatically any time you run `npm test`.
8+
//
9+
// > An additional eslintrc override file is included in the `assets/` folder
10+
// > right out of the box. This is specifically to allow for variations in acceptable
11+
// > global variables between front-end JavaScript code designed to run in the browser
12+
// > vs. backend code designed to run in a Node.js/Sails process.
13+
//
14+
// > Note: If you're using mocha, you'll want to add an extra override file to your
15+
// > `test/` folder so that eslint will tolerate mocha-specific globals like `before`
16+
// > and `describe`.
17+
// Designed for ESLint v4.
18+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19+
// For more information about any of the rules below, check out the relevant
20+
// reference page on eslint.org. For example, to get details on "no-sequences",
21+
// you would visit `http://eslint.org/docs/rules/no-sequences`. If you're unsure
22+
// or could use some advice, come by https://sailsjs.com/support.
23+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24+
25+
"env": {
26+
"node": true
27+
},
28+
29+
"parserOptions": {
30+
"ecmaVersion": 2018
31+
},
32+
33+
"globals": {
34+
// If "no-undef" is enabled below, be sure to list all global variables that
35+
// are used in this app's backend code (including the globalIds of models):
36+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37+
"Promise": true,
38+
"sails": true,
39+
"_": true
40+
// …and any others (e.g. `"Organization": true`)
41+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
42+
},
43+
44+
"rules": {
45+
"block-scoped-var": ["error"],
46+
"callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]],
47+
"camelcase": ["warn", {"properties":"always"}],
48+
"comma-style": ["warn", "last"],
49+
"curly": ["warn"],
50+
"eqeqeq": ["error", "always"],
51+
"eol-last": ["warn"],
52+
"handle-callback-err": ["error"],
53+
"indent": ["warn", 2, {
54+
"SwitchCase": 1,
55+
"MemberExpression": "off",
56+
"FunctionDeclaration": {"body":1, "parameters":"off"},
57+
"FunctionExpression": {"body":1, "parameters":"off"},
58+
"CallExpression": {"arguments":"off"},
59+
"ArrayExpression": 1,
60+
"ObjectExpression": 1,
61+
"ignoredNodes": ["ConditionalExpression"]
62+
}],
63+
"linebreak-style": ["error", "unix"],
64+
"no-dupe-keys": ["error"],
65+
"no-duplicate-case": ["error"],
66+
"no-extra-semi": ["warn"],
67+
"no-labels": ["error"],
68+
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
69+
"no-redeclare": ["warn"],
70+
"no-return-assign": ["error", "always"],
71+
"no-sequences": ["error"],
72+
"no-trailing-spaces": ["warn"],
73+
"no-undef": ["off"],
74+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75+
// ^^Note: If this "no-undef" rule is enabled (set to `["error"]`), then all model globals
76+
// (e.g. `"Organization": true`) should be included above under "globals".
77+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78+
"no-unexpected-multiline": ["warn"],
79+
"no-unreachable": ["warn"],
80+
"no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }],
81+
"no-use-before-define": ["error", {"functions":false}],
82+
"one-var": ["warn", "never"],
83+
"prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}],
84+
"quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}],
85+
"semi": ["warn", "always"],
86+
"semi-spacing": ["warn", {"before":false, "after":true}],
87+
"semi-style": ["warn", "last"]
88+
}
89+
90+
}

app/.gitignore

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
################################################
2+
# ┌─┐┬┌┬┐╦╔═╗╔╗╔╔═╗╦═╗╔═╗
3+
# │ ┬│ │ ║║ ╦║║║║ ║╠╦╝║╣
4+
# o└─┘┴ ┴ ╩╚═╝╝╚╝╚═╝╩╚═╚═╝
5+
#
6+
# > Files to exclude from your app's repo.
7+
#
8+
# This file (`.gitignore`) is only relevant if
9+
# you are using git.
10+
#
11+
# It exists to signify to git that certain files
12+
# and/or directories should be ignored for the
13+
# purposes of version control.
14+
#
15+
# This keeps tmp files and sensitive credentials
16+
# from being uploaded to your repository. And
17+
# it allows you to configure your app for your
18+
# machine without accidentally committing settings
19+
# which will smash the local settings of other
20+
# developers on your team.
21+
#
22+
# Some reasonable defaults are included below,
23+
# but, of course, you should modify/extend/prune
24+
# to fit your needs!
25+
#
26+
################################################
27+
28+
29+
################################################
30+
# Local Configuration
31+
#
32+
# Explicitly ignore files which contain:
33+
#
34+
# 1. Sensitive information you'd rather not push to
35+
# your git repository.
36+
# e.g., your personal API keys or passwords.
37+
#
38+
# 2. Developer-specific configuration
39+
# Basically, anything that would be annoying
40+
# to have to change every time you do a
41+
# `git pull` on your laptop.
42+
# e.g. your local development database, or
43+
# the S3 bucket you're using for file uploads
44+
# during development.
45+
#
46+
################################################
47+
48+
config/local.js
49+
50+
51+
################################################
52+
# Dependencies
53+
#
54+
#
55+
# When releasing a production app, you _could_
56+
# hypothetically include your node_modules folder
57+
# in your git repo, but during development, it
58+
# is always best to exclude it, since different
59+
# developers may be working on different kernels,
60+
# where dependencies would need to be recompiled
61+
# anyway.
62+
#
63+
# Most of the time, the node_modules folder can
64+
# be excluded from your code repository, even
65+
# in production, thanks to features like the
66+
# package-lock.json file / NPM shrinkwrap.
67+
#
68+
# But no matter what, since this is a Sails app,
69+
# you should always push up the package-lock.json
70+
# or shrinkwrap file to your repository, to avoid
71+
# accidentally pulling in upgraded dependencies
72+
# and breaking your code.
73+
#
74+
# That said, if you are having trouble with
75+
# dependencies, (particularly when using
76+
# `npm link`) this can be pretty discouraging.
77+
# But rather than just adding the lockfile to
78+
# your .gitignore, try this first:
79+
# ```
80+
# rm -rf node_modules
81+
# rm package-lock.json
82+
# npm install
83+
# ```
84+
#
85+
# [?] For more tips/advice, come by and say hi
86+
# over at https://sailsjs.com/support
87+
#
88+
################################################
89+
90+
node_modules
91+
92+
93+
################################################
94+
#
95+
# > Do you use bower?
96+
# > re: the bower_components dir, see this:
97+
# > http://addyosmani.com/blog/checking-in-front-end-dependencies/
98+
# > (credit Addy Osmani, @addyosmani)
99+
#
100+
################################################
101+
102+
103+
################################################
104+
# Temporary files generated by Sails/Waterline.
105+
################################################
106+
107+
.tmp
108+
109+
110+
################################################
111+
# Miscellaneous
112+
#
113+
# Common files generated by text editors,
114+
# operating systems, file systems, dbs, etc.
115+
################################################
116+
117+
*~
118+
*#
119+
.DS_STORE
120+
.netbeans
121+
nbproject
122+
.idea
123+
*.iml
124+
.vscode
125+
.node_history
126+
dump.rdb
127+
128+
npm-debug.log
129+
lib-cov
130+
*.seed
131+
*.log
132+
*.out
133+
*.pid
134+

0 commit comments

Comments
 (0)