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

Export için Scriptleri ekle #105

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
Binary file added .DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ node_modules
node_modules/
.env
package-lock.json
coverage
.DS_Store
.vscode
anonrig marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ localhost:8080/yardim?page=1&limit=1

Json Yolla
localhost:8080/yardim

- /models/yardimModel.js e bak
ÖRNEK JSON POSTU
* /models/Yardim.js e bak
ÖRNEK JSON POSTU

```
{
Expand Down
18 changes: 9 additions & 9 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ const NodeCache = require("node-cache");
let cacheInstance;

module.exports = {
createCacheInstance: function (callback) {
if (!cacheInstance) {
cacheInstance = new NodeCache();
console.log("cache instance created");
}
},
createCacheInstance: function (callback) {
if (!cacheInstance) {
cacheInstance = new NodeCache();
console.log("cache instance created");
}
},

getCache: function () {
return cacheInstance;
},
getCache: function () {
return cacheInstance;
},
};
56 changes: 26 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
require("dotenv").config();
const config = require("./config.js");
const cache = require("./cache.js");
const buildServer = require("./server/build.js");
require('dotenv').config()
const config = require('./config.js')
const cache = require('./cache.js')
const buildServer = require('./server/build.js')

const mongoose = require("mongoose");
const app = buildServer()

const app = buildServer();
const Database = require('./utils/Database')

// DB connection
mongoose
.connect(config.mongoUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
cache.createCacheInstance();
app.log.info("Connected to DB...");
return app.listen(
{
port: config.port,
host: "0.0.0.0",
},
(err, address) => {
if (config.NODE_ENV === "development") {
console.log(`Available routes: \n${app.printRoutes()}`);
}
},
);
})
.catch((error) => {
app.log.fatal("Uncaught error", error);
process.exit(0);
});
Database.connect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database'in icersindeki console.log'lari kaldiralim. Aksi taktirde uygulama calisirken 2 sefer log yazmis oluyoruz. console.log yerine her zaman fastify.log kullanalim.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabi

.then(() => {
cache.createCacheInstance()
app.log.info('Connected to DB...')
return app.listen(
{
port: config.port,
host: '0.0.0.0',
},
(err, address) => {
if (config.NODE_ENV === 'development') {
console.log(`Available routes: \n${app.printRoutes()}`)
}
}
)
})
.catch((error) => {
app.log.fatal('Uncaught error', error)
process.exit(0)
})
49 changes: 27 additions & 22 deletions lib/Check.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
class Check {
constructor() {}
constructor() {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter ve formatter calistirmamissin sanirim. npm run lint && npm run format calistirir misin?


isPhoneNumber(text) {
return /^((?:\+[0-9][-\s]?)?\(?0?[0-9]{3}\)?[-\s]?[0-9]{3}[-\s]?[0-9]{2}[-\s]?[0-9]{2})$/.test(text);
}
isPhoneNumber(text) {
return /^((?:\+[0-9][-\s]?)?\(?0?[0-9]{3}\)?[-\s]?[0-9]{3}[-\s]?[0-9]{2}[-\s]?[0-9]{2})$/.test(
text
)
}

arePhoneNumbers(phones = []) {
for (let i = 0; i < phones.length; i++) {
if (!this.isPhoneNumber(phones[i])) {
return false;
arePhoneNumbers(phones = []) {
for (let i = 0; i < phones.length; i++) {
if (!this.isPhoneNumber(phones[i])) {
return false
}
}
}
return true;
}
return true
}

hideEmailCharacters(email) {
const emailParts = email.split("@");
const username = emailParts[0];
const domain = emailParts[1].split(".");
const hiddenUsername = username.slice(0, 1) + username.slice(1).replace(/./g, "*");
const hiddenDomain = domain[0].slice(0, 1) + username.slice(1).replace(/./g, "*");
const hiddenEx = domain[1].slice(0, 1) + username.slice(1).replace(/./g, "*");
const hiddenEmail = `${hiddenUsername}@${hiddenDomain}.${hiddenEx}`;
return hiddenEmail;
}
hideEmailCharacters(email) {
const emailParts = email.split('@')
const username = emailParts[0]
const domain = emailParts[1].split('.')
const hiddenUsername =
username.slice(0, 1) + username.slice(1).replace(/./g, '*')
const hiddenDomain =
domain[0].slice(0, 1) + username.slice(1).replace(/./g, '*')
const hiddenEx =
domain[1].slice(0, 1) + username.slice(1).replace(/./g, '*')
const hiddenEmail = `${hiddenUsername}@${hiddenDomain}.${hiddenEx}`
return hiddenEmail
}
}

module.exports = Check;
module.exports = Check
80 changes: 80 additions & 0 deletions models/Yardim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const mongoose = require("mongoose");

// yardım istyenlerin model dosyası
const yardimSchema = new mongoose.Schema(
{
yardimTipi: {
// Gıda, İlaç, Enkaz, Isınma, Kayıp
type: String,
required: true,
},
adSoyad: {
type: String,
required: true,
},
telefon: {
type: String,
required: false,
},
yedekTelefonlar: {
type: [String],
required: false,
},
email: {
type: String,
required: false,
},
adres: {
type: String,
required: true,
},
adresTarifi: {
type: String,
required: false,
},
acilDurum: {
type: String,
enum: ["normal", "orta", "kritik"],
required: true,
},
kisiSayisi: {
type: String,
required: false,
},
yardimDurumu: {
type: String,
enum: ["bekleniyor", "yolda", "yapildi"],
required: true,
},
fizikiDurum: {
type: String,
required: false,
},
googleMapLink: {
type: String,
required: false,
},

tweetLink: {
type: String,
required: false,
},

fields: {
// Tüm alternatif kullanımlar için buraya json yollayın
type: Object,
required: false,
},

ip: {
type: String,
required: true,
select: false,
},
},
{ timestamps: true },
);

const Yardim = mongoose.model("yardim", yardimSchema);

module.exports = Yardim;
63 changes: 63 additions & 0 deletions models/YardimEt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const mongoose = require("mongoose");

// yardım edebilecek kişilerin model dosyası
const yardimEtSchema = new mongoose.Schema(
{
yardimTipi: {
// Yolcu Taşıma - konaklama - işmakinesi kullanma
type: String,
required: true,
},
adSoyad: {
type: String,
required: true,
},
telefon: {
type: String,
required: true,
},
yedekTelefonlar: {
type: [String],
required: false,
},
sehir: {
type: String,
required: true,
},
// TODO: ilçe geçici required false yapıldı
ilce: {
type: String,
required: false,
},
hedefSehir: {
type: String,
required: false,
},
aciklama: {
type: String,
required: false,
},
fields: {
// Tüm alternatif kullanımlar için buraya json yollayın
type: Object,
required: false,
},

yardimDurumu: {
type: String,
enum: ["bekleniyor", "yolda", "yapildi"],
required: true,
},

ip: {
type: String,
required: true,
select: false,
},
},
{ timestamps: true },
);

const YardimEt = mongoose.model("yardimet", yardimEtSchema);

module.exports = YardimEt;
40 changes: 40 additions & 0 deletions models/YardimKaydi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const mongoose = require("mongoose");
const { Schema } = require("mongoose");

const yardimKaydiSchema = new mongoose.Schema({
postId: {
type: Schema.Types.ObjectId,
ref: "Post",
required: true,
},
adSoyad: {
type: String,
required: true,
},
telefon: {
type: String,
required: false,
},
sonDurum: {
type: String,
enum: [
"yardim-bekleniyor",
"yardim-edildi",
"yetersiz-bilgi",
"yardim-edilemedi",
],
required: false,
},
email: {
type: String,
required: false,
},
aciklama: {
type: String,
required: true,
},
});

const YardimKaydi = mongoose.model("yardimkaydi", yardimKaydiSchema);

module.exports = YardimKaydi;
34 changes: 0 additions & 34 deletions models/iletisimModel.js

This file was deleted.

Loading