feat: Development server for core + plugins (#2448)

This commit is contained in:
Carlos R. L. Rodrigues
2022-10-21 10:53:06 -03:00
committed by GitHub
parent 4de4f20b46
commit b88cef2b1f
23 changed files with 762 additions and 14 deletions

View File

@@ -0,0 +1,17 @@
const { Customer } = require("@medusajs/medusa")
module.exports = async (connection) => {
const manager = connection.manager
const customer = await manager.create(Customer, {
id: "customer-1",
email: "test1@email.com",
first_name: "John",
last_name: "Doe",
password_hash:
"c2NyeXB0AAEAAAABAAAAAVMdaddoGjwU1TafDLLlBKnOTQga7P2dbrfgf3fB+rCD/cJOMuGzAvRdKutbYkVpuJWTU39P7OpuWNkUVoEETOVLMJafbI8qs8Qx/7jMQXkN",
// password matching "test"
has_account: true,
})
await manager.save(customer)
}

View File

@@ -0,0 +1,9 @@
const user = require("./user")
const region = require("./region")
const customer = require("./customer")
module.exports = async (db) => {
await user(db)
await region(db)
await customer(db)
}

View File

@@ -0,0 +1,45 @@
const { Region } = require("@medusajs/medusa")
module.exports = async (connection) => {
const manager = connection.manager
const r = manager.create(Region, {
id: "test-region",
name: "Test Region",
payment_providers: [{ id: "test-pay" }],
currency_code: "usd",
tax_rate: 0,
})
await manager.save(r)
const europeRegion = manager.create(Region, {
id: "eur-region",
name: "Europe Region",
payment_providers: [{ id: "test-pay" }],
currency_code: "eur",
tax_rate: 0,
})
await manager.save(europeRegion)
// Region with multiple countries
const regionWithMultipleCoutries = manager.create(Region, {
id: "test-region-multiple",
name: "Test Region",
currency_code: "eur",
tax_rate: 0,
})
await manager.save(regionWithMultipleCoutries)
await manager.query(
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'no'`
)
await manager.query(
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'dk'`
)
await manager.query(
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
)
}

View File

@@ -0,0 +1,17 @@
const Scrypt = require("scrypt-kdf")
const { User } = require("@medusajs/medusa")
module.exports = async (connection) => {
const manager = connection.manager
const buf = await Scrypt.kdf("secret_password", { logN: 1, r: 1, p: 1 })
const password_hash = buf.toString("base64")
await manager.insert(User, {
id: "admin_user",
email: "admin@medusa.js",
api_token: "test_token",
role: "admin",
password_hash,
})
}