Skip to content

Commit

Permalink
Merge pull request #30 from nais/refactor_migration
Browse files Browse the repository at this point in the history
Refactor migration
  • Loading branch information
thokra-nav authored Feb 20, 2024
2 parents f93daa9 + f02ec40 commit f9700a5
Show file tree
Hide file tree
Showing 98 changed files with 3,379 additions and 1,389 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_USER_EMAIL="dev.usersen@example.com"
4 changes: 3 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- refactor_migration
env:
NAME: console-frontend
IMAGE_REPOSITORY: oci://europe-north1-docker.pkg.dev/nais-io/nais
Expand Down Expand Up @@ -42,6 +43,8 @@ jobs:
rollout:
needs:
- build_push
# Only do this if on main
if: endsWith(github.ref, '/main')
runs-on: fasit-deploy
permissions:
id-token: write
Expand All @@ -50,4 +53,3 @@ jobs:
with:
chart: ${{ env.IMAGE_REPOSITORY }}/${{ env.NAME }}
version: ${{ needs.build_push.outputs.version }}
feature_name: ${{ env.NAME }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN npm ci --quiet --legacy-peer-deps

COPY . ./

ENV VITE_GRAPHQL_ENDPOINT http://console-backend/query
ENV VITE_GRAPHQL_ENDPOINT http://nais-api/query

RUN npm run build

Expand Down
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
# create-svelte
# Console frontend

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
## Development

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!
The following snippet contains the most important commands for development.

```bash
# create a new project in the current directory
npm create svelte@latest
npm install
cp .env.example .env # Copy the example environment file
npm run dev # Starts a development server on port 5173

# create a new project in my-app
npm create svelte@latest my-app
npm run check # Check for various issues
npm run lint # Lint the code
npm run format # Format the code (Or use a Prettier extension in your editor)
```

## Developing
## User

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
In production `api` uses oauth2 to authenticate users.
In developmen

```bash
npm run dev
### Local user override

# or start the server and open the app in a new browser tab
npm run dev -- --open
```
When running locally, the frontend will proxy requests to the backend through a Vite Proxy.
This proxy will add a special header for local development to specify which user to run as.

## Building
There's two well known users:

To create a production version of your app:
| User | Description |
| --------------------------- | ---------------------------------------------------- |
| `dev.usersen@example.com` | A user with tenant wide permissions, but owns a team |
| `admin.usersen@example.com` | A user with all permissions |

```bash
npm run build
```
You can specify which user to run as through `.env`.
See `.env.example` for an example.

You can preview the production build with `npm run preview`.
### Using OAUTH

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
To use the oauth flow, you need to configure `api` with correct credentials, and the user has to exist in the database.
2 changes: 1 addition & 1 deletion charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: console-frontend
description: Frontend for NAIS console
type: application
version: 1.0.0
version: 2024-02-13-104003-46227aa
sources:
- https://github.com/nais/console-frontend/tree/main/charts
2 changes: 1 addition & 1 deletion charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
image: '{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Chart.Version }}'
ports:
- name: http
containerPort: 8080
containerPort: 3000
protocol: TCP
resources:
requests:
Expand Down
2 changes: 1 addition & 1 deletion charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-buffer-size: 8k
spec:
ingressClassName: nais-ingress-iap
ingressClassName: nais-ingress
rules:
- host: '{{ .Values.host }}'
http:
Expand Down
2 changes: 1 addition & 1 deletion charts/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
- to:
- podSelector:
matchLabels:
app: console-backend
app: nais-api
podSelector:
matchLabels:
app: '{{ .Release.Name }}'
Expand Down
2 changes: 1 addition & 1 deletion charts/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
type: ClusterIP
ports:
- port: 80
targetPort: 3000
targetPort: http
protocol: TCP
name: http
selector:
Expand Down
9 changes: 7 additions & 2 deletions houdini.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
/** @type {import('houdini').ConfigFile} */
const config = {
watchSchema: {
url: 'http://127.0.0.1:4242/query'
url: 'http://127.0.0.1:3000/query'
},
plugins: {
'houdini-svelte': {}
},
scalars: {
Cursor: { type: 'string' },
Slug: { type: 'string' },
Date: {
type: 'Date',
unmarshal(val) {
Expand Down Expand Up @@ -39,6 +39,11 @@ const config = {
return date.toString();
}
}
},
types: {
Reconciler: {
keys: ['name']
}
}
};

Expand Down
62 changes: 25 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"format": "prettier --write ."
},
"devDependencies": {
"@nais/ds-svelte-community": "^0.7.1",
"@nais/ds-svelte-community": "^0.7.4",
"@nais/ds-svelte-community-preprocess-svelte": "^0.7.0",
"@navikt/ds-css": "^5.11.4",
"@sveltejs/adapter-auto": "^2.1.1",
Expand Down
Loading

0 comments on commit f9700a5

Please sign in to comment.