This is the Git repo for the page https://frilansaresverige.se/, including the
form for publishing consulting assignments (/uppdrag), which used to live on
uppdrag.frilansaresverige.se.
This is a Next.js project (App Router, TypeScript) that
runs on Node.js 26 (see .nvmrc).
npm install
cp .env.example .env.local # fill in what you need
npm run devOpen http://localhost:3000 with your browser to see the result.
The start page and the membership application work without any configuration.
The assignment form needs a MySQL database with the tables from the old
uppdrag repository's backend/structure.sql, and SMTP and Slack settings for
the confirmation e-mails and the Slack posts.
Other useful commands:
npm test # Vitest
npm run lint
npm run typecheck
npm run prettier:writeapp/uppdragholds the pages;app/uppdrag/actions.tsthe server actions that save assignments, comments and deletions.- Slack posts and the confirmation e-mail are sent after the response
(
after()), fromlib/slack.tsandlib/email.ts. The texts are inlib/templates.ts. - Anything that didn't reach Slack is retried when the server starts
(
instrumentation.ts). - The edit link (
/uppdrag/<id>) is the only credential, so it is never indexed and is masked in Google Analytics. - Old links to uppdrag.frilansaresverige.se are permanently redirected by the Nginx reverse proxy on karmosin.
Members can invite people through Slack's own invite function, but new
members are only accepted through the form at /ansokan. On the Free plan an
app can't decline invite requests itself, so the bot does the next best thing
(lib/inviteRequests):
- When Slackbot posts an invite request in the invite request channel, the bot sends the inviting member a direct message pointing them to the form, says so in the request's thread and adds a 📩 reaction. An admin then only has to press Deny.
- The reaction marks a request as handled. Every hour, and at startup, the bot goes through the last 24 hours of the channel and handles any request without it, in case an event never arrived.
- Workspace admins edit the direct message from fribot's Home tab in Slack,
where only they see the button that opens the editing dialog. Others can
be given access with
SLACK_TEMPLATE_EDITORS. The text is stored in theslackMessageTemplatetable (db/migrations); leaving it empty restores the default inlib/inviteRequests/template.ts. - Slack doesn't document the format of invite requests; the parser in
lib/inviteRequests/parse.tsfollows the real ones as of November 2026 and ignores anything it doesn't recognise. WithINVITE_REQUEST_DRY_RUN=true(the default, for e.g. a new workspace) the bot only writes in the request's thread what it would have sent. Production runs with it set tofalse.
In the app's settings at https://api.slack.com/apps:
- OAuth & Permissions: add the bot scopes
groups:history,reactions:writeandim:write(besides the existing ones), then reinstall the app. - Event Subscriptions: enable, set the request URL to
https://www.frilansaresverige.se/api/slack/eventsand subscribe to the bot eventsmessage.groupsandapp_home_opened. - Interactivity & Shortcuts: enable, with the request URL
https://www.frilansaresverige.se/api/slack/interactions. - App Home: turn on the Home Tab.
- Invite the bot to the invite request channel, and put the app's signing
secret and the channel in
SLACK_SIGNING_SECRETandSLACK_INVITE_REQUEST_CHANNEL.
The site has to be running with these settings (and the migration applied) before Slack will accept the request URLs, since it checks them.
lib/db/schema.ts describes the tables for
Drizzle. The application never alters them;
new tables are added with the SQL files in db/migrations, run by hand.
Possible improvements, none of them required:
assignmentComment.idis computed asCOUNT(*) + 1when inserting, so two comments saved at the same moment on the same assignment collide on the primary key and one of them fails. AnAUTO_INCREMENTid would avoid that.assignment.created/deletedare Unix seconds inbigint;DATETIMEorTIMESTAMPcolumns would be easier to read and query.clientHourlyRateis avarchar(20)although only integers are stored; anINT UNSIGNEDwould allow sorting and filtering.slackChannelstores a channel name (e.g.#uppdrag), which breaks if the channel is renamed before an assignment reaches Slack. Storing the channel id instead would also makeslackChannelIdunnecessary.- An index on
assignment.slackIdand on(deleted, slackDeleted)would keep the startup sync cheap as the table grows. - Deleted assignments keep their personal data (e-mail address, contact details) indefinitely. Clearing those columns some time after deletion would be kinder under GDPR.
deploy.sh runs deploy-app from the automation repository (settings in
deploy.conf): the tests, a build tagged with the commit, a vulnerability scan
and the release on gredelin, which waits for the container's healthcheck and
puts the previous release back if it fails (./deploy.sh rollback | status).
The container's configuration is in the automation repository
(ansible/host_vars/gredelin/apps.yml, frilansaresverige), and the variables
from .env.example are its secrets, in the vault there.
The Nginx on karmosin proxies www.frilansaresverige.se to it and must pass on
the Host header, which server actions check against Origin.
GOOGLE_ANALYTICS_ID is a build argument instead, as it ends up in the
statically rendered pages.
Bring your ideas to #frilansaresverigese in our Slack.
Fork & pull request - make sure to attach a screenshot of the effect of your change so it is easy to review 👍