Skip to content

Commit 9552e65

Browse files
committed
refactor: extract a local variable
1 parent 6be61e5 commit 9552e65

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/templates/routes.py.ejs

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ endpoints.forEach(function(endpoint) {
1616
const path = endpoint.path
1717
1818
endpoint.methods.forEach(function(method) {
19+
const hasGetOne = method.name === 'get'
20+
const hasGetMany = method.name === 'get_list'
1921
const pythonMethodName = generate_method_name(method.name, path)
2022
const sql = formatQuery(method.query)
2123
22-
if (method.name === 'get' || method.name === 'get_list') {
24+
if (hasGetOne || hasGetMany) {
2325
%>
2426
@router.get('<%- path %>')
2527
def <%- pythonMethodName %>():
26-
<% if (method.name === 'get') { -%>
28+
<% if (hasGetOne) { -%>
2729
conn = psycopg2.connect(
2830
database = os.getenv('DB_NAME'),
2931
user = os.getenv('DB_USER'),

0 commit comments

Comments
 (0)