-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into Folder-Structure
- Loading branch information
Showing
43 changed files
with
727 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Build applicaiton | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
services: | ||
# Label used to access the service container | ||
postgres: | ||
# Docker Hub image | ||
image: postgres | ||
# Provide the password for postgres | ||
env: | ||
POSTGRES_USER: entel | ||
POSTGRES_PASSWORD: crazypassword | ||
POSTGRES_DB: enteldb | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
# Maps tcp port 5432 on service container to the host | ||
- 5432:5432 | ||
env: | ||
DATABASE_URL: postgresql://entel:crazypassword@localhost:5432/enteldb | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "12.x" | ||
- name: Install dependencies | ||
id: install-dependencies | ||
run: yarn install | ||
- name: Migrate database | ||
id: migrate-database | ||
run: npx blitz prisma migrate deploy --preview-feature | ||
- name: Build application | ||
id: build-application | ||
run: npm run build | ||
- name: Run unittests | ||
id: run-unittests | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,95 @@ A hosted version can be found at [**entel.me**](https://www.entel.me/) | |
Many thanks to Roman for creating the cute logo 💖 | ||
|
||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! | ||
|
||
## Setup entel locally | ||
|
||
To run entel locally, you need to install [NodeJS](https://nodejs.org/en/) and [npm](https://www.npmjs.com/). Additionally, you should be able to run PostgreSQL on your machine. You can achieve this by | ||
|
||
- installing it natively on your computer or | ||
- via docker. | ||
|
||
### First steps ✨ | ||
|
||
But first of all, you have to clone and open this repository. | ||
|
||
```bash | ||
git clone https://github.com/entel-me/entel.git | ||
cd entel | ||
``` | ||
|
||
After that, you should be able to install the dependencies with npm. | ||
|
||
```bash | ||
npm i | ||
``` | ||
|
||
Great! Let's start with setting up environment variables. 🔥 | ||
|
||
### Setup enviroment variables 📝 | ||
|
||
First, you have to create two empty files`.env.local` and `env.test.local`. You can specify environment variables in these files. Afterward, you call them with `process.env.`. | ||
|
||
`DATABASE_URL` is an important variable that connects the PostgreSQL database with our application. If you're running PostgreSQL in docker, you set | ||
|
||
- username, | ||
- password, | ||
- the name of the database | ||
on your own and include them in a URL. Here is an example: | ||
|
||
```txt | ||
POSTGRES_USER=entel | ||
POSTGRES_PASSWORD=crazypassword | ||
POSTGRES_DB=enteldb | ||
DATABASE_URL=postgresql://entel:crazypassword@localhost:5432/enteldb | ||
``` | ||
|
||
If you're running PostgreSQL natively on your computer, you have to enter the URL of your database in each `.local` file. Please be aware that you have to remove the [`predev` script](https://github.com/entel-me/entel/blob/1f352942b6f9cec4aabad566766f752c4c3c82f5/package.json#L5) from package.json to run entel without errors. | ||
|
||
```txt | ||
DATABASE_URL=postgresql://entel:crazypassword@localhost:5432/enteldb | ||
``` | ||
|
||
If you want to test the mailer in [`mailers/`](https://github.com/entel-me/entel/tree/develop/mailers), you have to add your | ||
|
||
- mail, | ||
- password, | ||
- and mail host | ||
to the `.local` files too: | ||
|
||
```txt | ||
MAIL_HOST=mail.privateemail.com | ||
[email protected] | ||
MAIL_PASSWORD=crazypassword | ||
``` | ||
|
||
Great! After that, we take care of the database itself. | ||
|
||
### Run the database 📋 | ||
|
||
The last thing we have to do is migrating the database with [prisma](https://www.prisma.io/). For the following step, the database should already be running. You can achieve this with docker with the command: | ||
|
||
```bash | ||
docker-compose up -d | ||
``` | ||
|
||
Now you can set up the database by entering: | ||
|
||
```bash | ||
blitz prisma migrate dev --preview-feature | ||
``` | ||
|
||
Btw, if you change something in [schema.prisma](https://github.com/entel-me/entel/blob/develop/db/schema.prisma) you have to re-run the last command. | ||
Now we can try out our application. 🥳 | ||
|
||
### Run the application | ||
|
||
To run entel you execute | ||
|
||
```bash | ||
blitz dev | ||
``` | ||
|
||
and view your new app at [http://localhost:3000/](http://localhost:3000/)! Perfect 🎉 | ||
|
||
Have fun with the app :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import db from "db" | ||
import { Ctx } from "blitz" | ||
import { dbLogger as log } from "app/lib/logger" | ||
|
||
export default async function markMessagesAsRead({ chatId }, context: Ctx) { | ||
context.session.$authorize() | ||
await db.message.updateMany({ | ||
where: { sentInId: chatId, sentToId: context.session.userId }, | ||
data: { wasRead: true }, | ||
}) | ||
log.debug("Messages marked as read.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import db from "db" | ||
import { Ctx } from "blitz" | ||
import { dbLogger as log } from "app/lib/logger" | ||
|
||
export default async function updatePosition({ new_longitude, new_latitude }, context: Ctx) { | ||
context.session.$authorize() | ||
await db.user.update({ | ||
where: { id: context.session.userId }, | ||
data: { last_latitude: new_latitude, last_longitude: new_longitude }, | ||
}) | ||
log.info("A Position was updated.") | ||
} |
Oops, something went wrong.