Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/monorepo #18

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
context: ./packages/app
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Go to app folder
run: cd packages/app

- name: Publish to Github Pages
run: npm deploy
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

## Bakground

Detta är den blivande prototypen av matmarknaden byggd på dynamiskt inköpssystem DIS.
Detta är en prototyp av matmarknaden SKAFF för att visa hur enkelt ett dynamiskt inköpssystem (DIS) kan bli med hjälp av en app.

## Kom igång

Så här kommer du igång:

git clone https://github.com/iteam1337/foodMarket
cd foodMarket
cd foodMarket/packages/app

npm install
npm run ios

Nu startas automatiskt din iOS Simulator och du kan testa applikationen live där.

## Screenshots (ej färdig layout)
![image](https://user-images.githubusercontent.com/395843/232560646-26c641a6-429d-46cc-8b9d-1ed460c9e119.png)

![image](https://user-images.githubusercontent.com/395843/232560646-26c641a6-429d-46cc-8b9d-1ed460c9e119.png)

## LICENS

Expand Down
File renamed without changes.
85 changes: 85 additions & 0 deletions packages/api/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { Server } from 'socket.io'
import express from 'express'
import { createServer } from 'http'

import buyers from '../app/src/data/buyers'
import deals from '../app/src/data/deals'
import tenderRequests from '../app/src/data/tenderRequests'
const port = process.env.PORT || 3000
const app = express()
const server = createServer(app)
const io = new Server(server)

server.listen(port, () => {
console.log(`listening on *:${port}`)
})

const state = {
buyers: [],
deals: deals,
tenderRequests: tenderRequests,
suppliers: [],
categories: [],
}

const reset = () =>
Object.assign(state, {
buyers: buyers,
deals: deals,
tenderRequests: tenderRequests,
suppliers: [],
categories: [],
})

// either provide socket or io - if you provide io then it will send to all sockets
const sync = (socket: any) => {
console.log(
'syncing',
state.deals.length,
'deals',
state.tenderRequests.length,
'tenderRequests'
)
socket.emit('tenderRequests', state.tenderRequests)
socket.emit('suppliers', state.suppliers)
socket.emit('buyers', state.buyers)
}

io.on('connection', (socket) => {
console.log('a user connected')
socket.on('reset', () => reset() && sync(io))

socket.on('deals', () => socket.emit('deals', state.deals))
socket.on('buyers', () => socket.emit('buyers', state.buyers))
socket.on('tenderRequests', () =>
socket.emit('tenderRequests', state.tenderRequests)
)

// DEALS
socket.on('addDeal', (deal) => {
state.deals.push(deal)
io.emit('deals', state.deals)
})

socket.on('editDeal', (deal) => {
const index = state.deals.findIndex((d) => d.id === deal.id)
state.deals[index] = deal
io.emit('deals', state.deals)
})

// TENDER REQUESTS
socket.on('addTenderRequest', (tenderRequest) => {
state.tenderRequests.push(tenderRequest)
io.emit('tenderRequests', state.tenderRequests)
})

socket.on('editTenderRequest', (tenderRequest) => {
const index = state.tenderRequests.findIndex(
(d) => d.id === tenderRequest.id
)
state.tenderRequests[index] = tenderRequest
io.emit('tenderRequests', state.tenderRequests)
})
})

reset()
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN npm install -g expo-cli
RUN npm install @types/[email protected]
COPY . .
EXPOSE 19000
CMD ["expo", "start"]
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading