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: development server #2448

Merged
merged 32 commits into from
Oct 21, 2022
Merged

feat: development server #2448

merged 32 commits into from
Oct 21, 2022

Conversation

carlos-r-l-rodrigues
Copy link
Contributor

What:

Initial iteration for a simple development server of medusa core.
yarn run develop:create:db - Creates the database and seed it.
yarn run develop - Initialize the core as a server and auto reload when files are changed.

@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2022

⚠️ No Changeset found

Latest commit: 21743e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@adrien2p
Copy link
Member

Seams pretty cool from a first look, i ll look at deeper next week 💪

@carlos-r-l-rodrigues carlos-r-l-rodrigues marked this pull request as ready for review October 17, 2022 20:56
@carlos-r-l-rodrigues carlos-r-l-rodrigues requested a review from a team as a code owner October 17, 2022 20:56
@srindom
Copy link
Collaborator

srindom commented Oct 18, 2022

Is the idea with this PR that you can do yarn develop while working on Medusa to avoid having a "dummy-project" that you run medusa-dev in?

@carlos-r-l-rodrigues
Copy link
Contributor Author

carlos-r-l-rodrigues commented Oct 18, 2022

Is the idea with this PR that you can do yarn develop while working on Medusa to avoid having a "dummy-project" that you run medusa-dev in?

The idea is to have a develop mode to medusa core and all the built-in plugins. Currently we have no easy way to update a plugin or create a new endpoint and easily test it while developing.
This PR will run ts-node to execute all the files directly from the /src folder and auto reload them when something has changed.
All the endpoints will be accessible so you can manually trigger requests to test.

@srindom
Copy link
Collaborator

srindom commented Oct 19, 2022

I get this when yarn run develop:create:db

@srindom srindom closed this Oct 19, 2022
@srindom
Copy link
Collaborator

srindom commented Oct 19, 2022

Creating DB...
/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/src/error/TypeORMError.ts:7
        super(message);
        ^
QueryFailedError: template database "medusa-integration-template" does not exist
    at QueryFailedError.TypeORMError [as constructor] (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/src/error/TypeORMError.ts:7:9)
    at new QueryFailedError (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/src/error/QueryFailedError.ts:9:9)
    at PostgresQueryRunner.<anonymous> (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/typeorm/src/driver/postgres/PostgresQueryRunner.ts:263:19)
    at step (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/tslib/tslib.js:144:27)
    at Object.throw (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/tslib/tslib.js:125:57)
    at rejected (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/tslib/tslib.js:116:69)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  query: 'CREATE DATABASE "development" TEMPLATE "medusa-integration-template";',
  parameters: undefined,
  driverError: error: template database "medusa-integration-template" does not exist
      at Parser.parseErrorMessage (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/pg-protocol/src/parser.ts:369:69)
      at Parser.handlePacket (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/pg-protocol/src/parser.ts:188:21)
      at Parser.parse (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/pg-protocol/src/parser.ts:103:30)
      at Socket.<anonymous> (/Users/sebastianrindom/Developer/medusa/medusa-js/node_modules/pg-protocol/src/index.ts:7:48)
      at Socket.emit (node:events:513:28)
      at Socket.emit (node:domain:489:12)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    length: 119,
    severity: 'ERROR',
    code: '3D000',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'dbcommands.c',
    line: '357',
    routine: 'createdb'
  },
  length: 119,
  severity: 'ERROR',
  code: '3D000',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'dbcommands.c',
  line: '357',
  routine: 'createdb'
}

@srindom srindom reopened this Oct 19, 2022
@carlos-r-l-rodrigues
Copy link
Contributor Author

I get this when yarn run develop:create:db

Fixed. Thanks

@olivermrbl
Copy link
Contributor

olivermrbl commented Oct 20, 2022

I am faced with the following error message when trying to seed the DB:

Creating DB...
Creating DB. DONE
Seeding DB...
Error TypeError: this.subQuery is not a function
    at InsertQueryBuilder.QueryBuilder.createFromAlias (/Users/oliverjuhl/Desktop/medusa/core/node_modules/src/query-builder/QueryBuilder.ts:599:127)
    at InsertQueryBuilder.into (/Users/oliverjuhl/Desktop/medusa/core/node_modules/src/query-builder/InsertQueryBuilder.ts:187:32)
    at EntityManager.<anonymous> (/Users/oliverjuhl/Desktop/medusa/core/node_modules/src/entity-manager/EntityManager.ts:466:14)
    at step (/Users/oliverjuhl/Desktop/medusa/core/node_modules/tslib/tslib.js:144:27)
    at Object.next (/Users/oliverjuhl/Desktop/medusa/core/node_modules/tslib/tslib.js:125:57)
    at /Users/oliverjuhl/Desktop/medusa/core/node_modules/tslib/tslib.js:118:75
    at new Promise (<anonymous>)
    at __awaiter (/Users/oliverjuhl/Desktop/medusa/core/node_modules/tslib/tslib.js:114:16)
    at EntityManager.insert (/Users/oliverjuhl/Desktop/medusa/core/node_modules/typeorm/entity-manager/EntityManager.js:277:38)
    at /Users/oliverjuhl/Desktop/medusa/core/integration-tests/development/database/user.js:10:17
Seeding DB... DONE

From what I can find via Google search, this is likely to be related to a couple of missing environment variables, but before proceeding with the investigation, I wanted to check if you'd experienced the same issue before?

@olivermrbl
Copy link
Contributor

This is really awesome @carlos-r-l-rodrigues!

How should we proceed?

We could add additional seeders, or let more from the team spin up the development server to ensure it works in more local environments. Let me know what you think :)

@carlos-r-l-rodrigues
Copy link
Contributor Author

Ideally we have more people trying it before merging this, and following that we can have another PR seeding the DB with all the required data.
Next steps we add support to feature flags on the seeders.

@olivermrbl
Copy link
Contributor

Ideally we have more people trying it before merging this

Sounds good!

@olivermrbl
Copy link
Contributor

Would be great to run a couple more tests on local machines. Is anyone up for the task? @medusajs/engineering

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

LGTM!

@olivermrbl olivermrbl merged commit b88cef2 into develop Oct 21, 2022
@olivermrbl olivermrbl deleted the feat/development-server branch October 21, 2022 13:53
ymaheshwari1 pushed a commit to ymaheshwari1/medusa that referenced this pull request Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants