| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Launch a fully featured SN development environment in a single command.
$ ./sndev startGo to localhost:3000.
You can run Stacker News on Github Codespaces
After the codespace is created, the development environment will be automatically set up and services started.
Access your running application at the URL shown in the forwarded ports panel (typically https://your-codespace-name-3000.app.github.dev).
⚠️ Important: For various internal services and external access to work properly, you must set forwarded ports to Public in the Ports tab:
Start the development environment
$ ./sndev startView all available commands
$ ./sndev help
888
888
888
.d8888b 88888b. .d88888 .d88b. 888 888
88K 888 '88b d88' 888 d8P Y8b 888 888
'Y8888b. 888 888 888 888 88888888 Y88 88P
X88 888 888 Y88b 888 Y8b. Y8bd8P
88888P' 888 888 'Y88888 'Y8888 Y88P
manages a docker based stacker news development environment
USAGE
$ sndev [COMMAND]
$ sndev help [COMMAND]
COMMANDS
help show help
env:
start start env
stop stop env
restart restart env
status status of env
logs logs from env
delete delete env
sn:
login login as a nym
set_balance set the balance of a nym
lightning:
fund pay a bolt11 for funding
withdraw create a bolt11 for withdrawal
db:
psql open psql on db
prisma run prisma commands
domains:
domains custom domains dev management
dev:
pr fetch and checkout a pr
lint run linters
test run tests
other:
cli service cli passthrough
open open service GUI in browser
onion service onion address
cert service tls cert
compose docker compose passthroughBy default all services will be run. If you want to exclude specific services from running, set COMPOSE_PROFILES in a .env.local file to one or more of minimal,images,search,payments,wallets,email,capture,domains,domains-caddy. To only run minimal necessary without things like payments in .env.local:
COMPOSE_PROFILES=minimalTo run with images and payments services:
COMPOSE_PROFILES=images,paymentsBy default sndev start will merge docker-compose.yml with docker-compose.override.yml. Specify any overrides you want to merge with docker-compose.override.yml.
For example, if you want to replace the db seed with a custom seed file located in docker/db/another.sql, you'd create a docker-compose.override.yml file with the following:
services:
db:
volumes:
- ./docker/db/another.sql:/docker-entrypoint-initdb.d/seed.sqlYou can read more about docker compose override files.
Semantic search is now enabled automatically in dev when the search profile is active.
Ensure search is in COMPOSE_PROFILES:
COMPOSE_PROFILES=...,search,...Start your environment with ./sndev start.
On first boot, OpenSearch downloads and deploys the embedding model, then creates a neural-ready index. This can take a couple minutes.
No manual script run or container restart is required for the default setup.
If you need to manually repair or recreate semantic search resources, restart from a fresh dev volume with ./sndev delete and then run ./sndev start.
To enable dnsmasq:
domains should be enabled in COMPOSE_PROFILES:
COMPOSE_PROFILES=...,domains,...To add/remove DNS records you can now use ./sndev domains dns. More on this here.
The domains profile enables dnsmasq and custom-domain worker jobs. The bundled Caddy HTTPS proxy is separate in domains-caddy, so you can keep local domain verification while omitting Caddy if an external TLS-terminating load balancer handles your dev domains.
We want your help.
View a current list of granted awards
This document in no way legally entitles you to payments for contributions, entitles you to being a contributor, or entitles you to the attention of other contributors. This document lays out the system we can use to determine contribution awards which we generally intend to abide by but importantly we reserve the right to refuse payments or contributions, modify rules and award amounts, make exceptions to rules or reward amounts, and withhold awards for any reason at anytime, even just for the heck of it, at our sole discretion. If you need more certainty than what I've just described, don't participate. We provide awards as an experiment to make FOSS less sucky.
Due to Rule 3, make sure that you mark your PR as a draft when you create it and it's not ready for review yet.
| tag | description | award |
|---|---|---|
| difficulty:good-first-issue | at most a couple lines of code in a couple files and does not require much familiarity with the codebase | 20k sats |
| difficulty:easy | at most a couple lines of code in a couple files but does require familiarity with the code base | 100k sats |
| difficulty:medium | more code, more places and could require adding columns in the db and some modification chunky db queries | 250k sats |
| difficulty:medium-hard | even more code, even more places and requires either more sophisticated logic, more significant db modeling eg adding a table, and/or a deeper study of a something | 500k sats |
| difficulty:hard | either a bigger lift than the what's required of medium-hard or very tricky in a particular way that might not require a lot of code but does require a lot of context/troubleshooting/expertise | 1m sats |
| tag | multiplier |
|---|---|
| priority:low | 0.5 |
| priority:medium | 1.5 |
| priority:high | 2 |
| priority:urgent | 3 |
We try to assign difficulty and priority tags to issues accurately, but we're not perfect. If you believe an issue is mis-tagged, you can request a change to the issue's tags.
Code reviewers will be awarded the amount their code review reduced from the PR author's reward, e.g. two substantial problems/areas of improvement identified in a PR closing a priority:high and difficulty:hard issue awards 400k sats.
Code review approvals are more than welcome, but we can't guarantee awards for them because the work performed to approve a PR is unverifiable.
Issue specifiers will be awarded up to 10% of a PR award for issues resulting in a PR being merged by an SN engineer that closes the issue. In addition to being subject to PR award amounts and reductions, specification amounts are awarded on the basis of how much additional help and specification is required by other contributors.
| circumstances | award |
|---|---|
| issue doesn't require further help and/or specification from other contributors | 10% |
| issue requires little help and/or specification from other contributors | 5% |
| issue requires more help and/or specification from other contributors than the issue specifier contributed | 1% |
| issue is vague and/or incomplete and must mostly be entirely specified by someone else | 0% |
For example: a specified issue that's tagged as difficulty:hard, doesn't require additional specification and disambiguation by other contributors, and results in PR being merged without changes requested awards the issue specifier 100k sats.
Awards for responsible disclosures are assessed on the basis of:
Award amounts will be easiest to assess on a case by case basis. Upon confirmation of a vulnerability, we agree to award responsible disclosures at minimum 100k sats and as high as the total potential loss that would result from exploiting the vulnerability.
For significant changes to documentation, create an issue before making said changes. In such cases we will award documentation improvements in accordance with issue specification and PR awards.
For changes on the order of something like a typo, we'll award a nominal amount at our discretion.
Like issue specification awards, helping fellow contributors substantially in a well documented manner such that the helped fellow contributes a merged PR is eligible for a one-time relative reward.
| circumstances | award |
|---|---|
| substantial and singular source of help | 10% |
| substantial but nonsingular source of help | 1-5% |
| source of relatively trivial help | 1% |
We want to make contributing to SN as rewarding as possible, so we offer a few extras to contributors.
We self-host a private chat server for contributors to SN. If you'd like to join, please respond in this discussion.
We offer triage permissions to contributors after they've made a few contributions. I'll usually add them as I notice people contributing, but if I missed you and you'd like to be added, let me know!
Contributors can get badges on their SN profiles by opening a pull request adding their SN nym to the contributors.txt file.
In the future we plan to offer more, like gratis github copilot subscriptions, reverse tunnels, codespaces, and merch.
If you'd like to see something added, please make a suggestion.
We use JavaScript Standard Style to enforce code style and correctness. You should run sndev lint before submitting a PR.
If you're using VSCode, you can install the StandardJS VSCode Extension extension to get linting in your editor. We also recommend installing StandardJS code snippets and StandardJS react code snippets for code snippets.
We use prisma for our database migrations. To create a new migration, modify prisma/schema.prisma according to prisma schema reference and apply it with:
./sndev prisma migrate dev
If you want to create a migration without applying it, eg to create a trigger or modify the generated sql before applying, use the --create-only option:
./sndev prisma migrate dev --create-only
Generate the local copy of the prisma ORM client in node_modules after changes. This should only be needed to get Intellisense in your editor locally.
./sndev prisma generate
You can connect to the local database via ./sndev psql. psql is an interactive terminal for working with PostgreSQL.
You can run lncli on the local lnd nodes via ./sndev cli lnd and ./sndev cli sn_lnd. The node for your local SN instance is sn_lnd and the node serving as any external node, like a stacker's node or external wallet, is lnd.
You can run lightning-cli on the local cln node via ./sndev cli cln which serves as an external node or wallet.
You can login to test features like posting, replying, tipping, etc with ./sndev login <nym> which will provide a link to login as an existing nym or a new account for a nonexistent nym. But, it you want to test auth specifically you'll need to configure them in your .env file.
http://localhost:3000/api/auth/callback/email?email=satoshi%40gmail.com&token=110e30a954ce7ca643379d90eb511640733de405f34a31b38eeda8e254d48cd7
LOGIN_EMAIL_SERVER=smtp://apikey:<sendgrid_api_key>@smtp.sendgrid.net:587 LOGIN_EMAIL_FROM=<sendgrid_email_from>
http://localhost:3000/api/auth/callback/email?email=satoshi%40gmail.com&token=110e30a954ce7ca643379d90eb511640733de405f34a31b38eeda8e254d48cd7
GITHUB_ID=<Client ID> GITHUB_SECRET=<Client secret>
To enable Web Push locally, you will need to set the VAPID_* env vars. VAPID_MAILTO needs to be an email address using the mailto: scheme. For NEXT_PUBLIC_VAPID_PUBKEY and VAPID_PRIVKEY, you can run npx web-push generate-vapid-keys.
A worker dedicated to verifying custom domains, checks, among other things, if a domain has the correct DNS records and values. This would normally require a real domain and access to its DNS configuration. Therefore we use dnsmasq to have local DNS, make sure you have enabled it.
If you access local custom domains through the bundled Caddy proxy, keep domains-caddy enabled too. If you use your own TLS-terminating load balancer, it should forward X-Forwarded-Proto: https so dev cookies that depend on secure requests are marked Secure.
To add a DNS record the syntax is the following:
./sndev domains dns add|remove cname|txt <name/domain> <value>
For TXT records, you can also use "" quoted strings on value.
To list all DNS records present in the dnsmasq config: ./sndev domains dns list
sndev will use the dnsmasq DNS server by default, but chances are that you might want to access the domain via your browser.
For every edit on dnsmasq, it will give you the option to either edit the /etc/hosts file or use the dnsmasq DNS server which can be reached on 127.0.0.1:5353. You can avoid getting asked to edit the /etc/hosts file by adding the --no-hosts parameter.
The site is written in javascript (not typescript 😱) using Next.js, a React framework. The backend API is provided via GraphQL. The database is PostgreSQL modeled with Prisma. The job queue is also maintained in PostgreSQL. We use lnd for our lightning node. A customized Bootstrap theme is used for styling.
Currently, SN runs and maintains two significant services and one microservice:
In addition, we run other critical services the above services interact with like lnd, postgres, opensearch, tor, and s3.
To ensure stackers balances are kept sane, some wallet updates are run in serializable transactions at the database level. Because early versions of prisma had relatively poor support for transactions most wallet touching code is written in plpgsql stored procedures and can be found in the prisma/migrations folder.
UPDATE: Most wallet updates are now run in read committed transactions. See api/payIn/README.md for more information.
Open a discussion or issue or email us or request joining the dev chat.
If you found a vulnerability, we would greatly appreciate it if you contact us via security@stacker.news or open a security advisory. Our PGP key can be found here (FEE1 E768 E0B3 81F5).
| Back | FazBrowse Home | New Git URL |