-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement mongodb persistent storage with express server
- Loading branch information
Showing
18 changed files
with
1,485 additions
and
132 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
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 +1,2 @@ | ||
FMP_KEY="<your_api_key>" | ||
EXPRESS_URI="http://localhost:3000/api/get/tickers" |
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,22 +1,17 @@ | ||
<script setup lang="ts"> | ||
import { useTickerStore } from '@/store/ticker'; | ||
import { computed } from 'vue'; | ||
import type { TickerData, SizeType } from '@/types/types'; | ||
import type { SizeType } from '@/types/types'; | ||
import TickerBox from '@/components/ticker/TickerBox.vue'; | ||
const { tickerId } = defineProps<{ | ||
const { tickerId, tickerType } = defineProps<{ | ||
tickerId: string; | ||
tickerType: string; | ||
}>(); | ||
const tickerStore = useTickerStore(); | ||
const ticker = computed<TickerData>(() => { | ||
return tickerStore.tickerValue(tickerId); | ||
}); | ||
const boxSize = 'LARGE' as SizeType; | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-wrap justify-center m-auto w-full h-full"> | ||
<TickerBox :ticker-id="ticker.id" :box-size="boxSize" r-link="/"></TickerBox> | ||
<TickerBox :ticker-id="tickerId" :ticker-type="tickerType" :box-size="boxSize" r-link="/"></TickerBox> | ||
</div> | ||
</template> |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PORT=3000 | ||
MONGO_URI=mongodb://mongodb-server/stocktracker |
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,9 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/prettierrc", | ||
"semi": true, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"endOfLine": "auto", | ||
"trailingComma": "none" | ||
} |
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,15 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
const MONGO_URI = process.env.MONGO_URI || 'mongodb://localhost:27017/stocktracker'; | ||
|
||
const connectDB = async () => { | ||
try { | ||
await mongoose.connect(MONGO_URI); | ||
console.log('MongoDB is connected'); | ||
} catch (e) { | ||
console.log(e); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
export default connectDB; |
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,18 @@ | ||
import { Schema, model } from 'mongoose'; | ||
|
||
const cryptoSchema = new Schema({ | ||
crypto: { | ||
type: String, | ||
required: true | ||
} | ||
}); | ||
|
||
const stockSchema = new Schema({ | ||
stock: { | ||
type: String, | ||
required: true | ||
} | ||
}); | ||
|
||
export const Cryptos = model('Cryptos', cryptoSchema); | ||
export const Stocks = model('Stocks', stockSchema); |
Oops, something went wrong.